25 #include <Classes.hpp>
26 #include <Controls.hpp>
27 #include <StdCtrls.hpp>
29 #include <Buttons.hpp>
30 #include <ExtCtrls.hpp>
32 #include <Dialogs.hpp>
33 #include <Graphics.hpp>
34 #include <ComCtrls.hpp>
50 #pragma package(smart_init)
63 Graphics::TBitmap* SmallGraphicPtrVal) : SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
65 for(
int x = 0; x < 4; x++)
76 else if(SpeedTagVal == 77)
80 else if(SpeedTagVal == 78)
84 else if(SpeedTagVal == 79)
88 else if(SpeedTagVal == 96)
92 else if(SpeedTagVal == 129)
96 else if(SpeedTagVal == 130)
100 else if(SpeedTagVal == 131)
104 else if(SpeedTagVal == 145)
108 else if(SpeedTagVal == 146)
117 FixedNamedLocationElement(false)
119 for(
int x = 0; x < 4; x++)
130 AnsiString(VLocInput));
143 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
157 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
173 Graphics::TBitmap *GraphicOutput = GraphicPtr;
175 if(LocationName ==
"")
220 GraphicOutput = GraphicPtr;
224 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
226 if((TrackType ==
Simple) && Failed)
238 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
239 AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit01) +
"," + AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit23) +
",EndTrkEl,";
248 Attribute(0), CallingOnSet(false), Length01(
Utilities->DefaultTrackLength), Length23(-1), SpeedLimit01(
Utilities->DefaultTrackSpeedLimit), SpeedLimit23(-1),
249 TrainIDOnElement(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit01(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit23(-1), StationEntryStopLinkPos1(-1),
250 StationEntryStopLinkPos2(-1), StationEntryStopLinkPos3(-1), StationEntryStopLinkPos4(-1), SigAspect(FourAspect)
253 for(
int x = 0; x < 4; x++)
269 if(lower.second < higher.second)
273 else if(lower.second > higher.second)
277 else if(lower.second == higher.second)
279 if(lower.first < higher.first)
292 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
293 CheckCount(9), IsARoute(false), AutoSignals(false), PrefDirRoute(false)
297 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
308 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
336 {2, 4}, {6, 2}, {8, 6}, {4, 8},
337 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
347 else if(
Link[2] == -1)
360 else if(
Link[2] == -1)
369 for(
int x = 0; x < 16; x++)
371 if(((Entry == EXArray[x][0]) && (Exit == EXArray[x][1])) || ((Entry == EXArray[x][1]) && (Exit == EXArray[x][0])))
547 throw Exception(
"Error in EntryExitNumber 4");
642 throw Exception(
"Error in EntryExitNumber 5");
736 throw Exception(
"Error in EntryExitNumber 6");
823 throw Exception(
"Error in EntryExitNumber 10");
912 throw Exception(
"Error in EntryExitNumber 11");
1008 throw Exception(
"Error in EntryExitNumber 7");
1039 throw Exception(
"Error in EntryExitNumber 8");
1050 if((ELink > 0) && (ELink < 10) && (ELink != 5))
1052 if(!AutoSigsFlag && !PrefDirRoute)
1056 else if(!AutoSigsFlag && PrefDirRoute)
1067 throw Exception(
"Error in EntryExitNumber 9");
1164 AnsiString NL =
'\n';
1166 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable, perhaps because of failed points; " + NL + NL +
1167 "reachable but too far ahead or with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
1168 "blocked by a train, another route or a changing level crossing; " + NL + NL +
1169 "or invalid - possibly due to a preferred direction mismatch, or a missed signal in a blue route or green route restricted to consecutive signals.";
1178 int InternalLinkCheckArray[9][2] =
1179 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
1184 for(
int x = 0; x < 9; x++)
1186 for(
int y = 0; y < 2; y++)
1193 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
1195 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
1196 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
1197 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
1198 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 << 18 << 19 << 20 << 21 << 22 << 23 << 24
1199 << 25 << 26 << 27 << 28 << 29 << 30 << 31 << 32 << 33 << 34 << 35 << 36 << 37 << 38 << 39 << 40 << 41 << 42 << 43 << 44 << 45 << 46 << 47
1200 << 60 << 61 << 62 << 63 << 64 << 65 << 66 << 67 << 68 << 69 << 70 << 71 << 72 << 73 << 74 << 75 << 80 << 81 << 82 << 83 << 84 << 85 << 86
1201 << 87 << 125 << 126 << 127 << 128 << 132 << 133 << 134 << 135 << 136 << 137 << 138 << 139
1202 << 140 << 141 << 142 << 143;
1207 int HVArray[10][2] =
1208 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
1210 for(
int x = 0; x < 10; x++)
1212 for(
int y = 0; y < 2; y++)
1221 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1224 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1225 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1227 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
1228 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
1230 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1231 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1234 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1237 for(
int x = 0; x < 40; x++)
1243 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1246 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1247 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1249 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1250 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1252 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1253 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1256 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1259 for(
int x = 0; x < 40; x++)
1265 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1268 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
1269 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1271 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1272 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1274 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1275 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1278 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1281 for(
int x = 0; x < 40; x++)
1307 for(
int x = 0; x < 40; x++)
1313 {{68, 0,
RailGraphics->
FSig68}, {69, 0,
RailGraphics->
FSig69}, {70, 0,
RailGraphics->
FSig70}, {71, 0,
RailGraphics->
FSig71}, {72, 0,
RailGraphics->
FSig72},
1316 for(
int x = 0; x < 8; x++)
1322 {{68, 0,
RailGraphics->
FGSig68}, {69, 0,
RailGraphics->
FGSig69}, {70, 0,
RailGraphics->
FGSig70}, {71, 0,
RailGraphics->
FGSig71}, {72, 0,
RailGraphics->
FGSig72},
1325 for(
int x = 0; x < 8; x++)
1352 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1353 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1354 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1355 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1356 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1357 {0, 0, 129}, {0, -1, 145},
1360 for(
int x = 0; x < 25; x++)
1362 for(
int y = 0; y < 3; y++)
1370 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1371 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1372 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1373 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1374 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1375 {0, 0, 129}, {0, 1, 145},
1378 for(
int x = 0; x < 25; x++)
1380 for(
int y = 0; y < 3; y++)
1388 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1389 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1390 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1391 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1392 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1393 {0, 0, 130}, {-1, 0, 146},
1396 for(
int x = 0; x < 25; x++)
1398 for(
int y = 0; y < 3; y++)
1406 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1407 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1408 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1409 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1410 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1411 {0, 0, 130}, {1, 0, 146},
1414 for(
int x = 0; x < 25; x++)
1416 for(
int y = 0; y < 3; y++)
1424 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1425 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1426 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1427 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1428 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1429 {0, -1, 129}, {1, 0, 130},
1430 {-1, 0, 130}, {0, 1, 145},
1431 {0, -1, 145}, {1, 0, 146},
1434 for(
int x = 0; x < 28; x++)
1436 for(
int y = 0; y < 3; y++)
1454 for(
int x = 0; x < 8; x++)
1456 for(
int y = 0; y < 3; y++)
1474 for(
int x = 0; x < 8; x++)
1476 for(
int y = 0; y < 3; y++)
1494 for(
int x = 0; x < 8; x++)
1496 for(
int y = 0; y < 3; y++)
1514 for(
int x = 0; x < 8; x++)
1516 for(
int y = 0; y < 3; y++)
1524 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1526 for(
int x = 0; x < 4; x++)
1528 for(
int y = 0; y < 3; y++)
1536 0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1537 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1538 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1539 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1545 0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1546 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1547 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1548 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1554 0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1555 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1556 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1557 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1563 0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1564 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1565 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1566 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1588 delete UGMIt->second;
1664 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1665 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1667 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1674 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1675 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1688 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1689 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1691 {4, 6, 2, 8}, {1, 9, 3, 7},
1693 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1695 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8}, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1698 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1699 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6}, {3, 7, 4, 6},
1700 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1701 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1},
1702 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1703 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1704 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1706 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1707 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1708 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1709 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1710 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1711 {4, 6, -1, -1}, {2, 8, -1, -1},
1713 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1715 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1717 {4, 6, -1, -1}, {2, 8, -1, -1},
1722 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1723 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1724 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1725 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1728 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1729 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1730 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1732 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1733 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1734 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1736 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1738 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1739 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1740 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1741 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1742 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1743 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1744 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1745 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1746 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1747 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1748 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1749 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1750 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1752 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1753 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1754 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1755 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1756 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1757 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1758 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1759 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1763 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1764 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1765 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1771 for(
int x = 0; x < 17; x++)
1773 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1775 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1779 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1785 ExistingGraphicLoaded(false), Width(16), Height(16)
1797 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1835 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1839 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1843 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1847 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1870 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1873 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1877 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1881 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1915 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1936 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1950 bool TrackPresent =
false;
1964 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1968 TrackPresent =
true;
1973 return(!TrackPresent);
1981 bool TrackPresent =
false;
1990 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1994 TrackPresent =
true;
2000 return(!TrackPresent);
2008 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2009 TrackEraseSuccessfulFlag =
false;
2014 ErasedTrackVectorPosition = -1;
2015 AnsiString SName =
"", ErrorString;
2017 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
2021 bool ActiveElementErased =
false;
2022 bool InactiveElementErased =
false;
2023 bool FootCrossingErased =
false;
2027 TrackMapKeyPair.first = HLocInput;
2028 TrackMapKeyPair.second = VLocInput;
2029 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
2041 if(ErrorString !=
"")
2043 throw Exception(ErrorString +
" for EraseTrackElement 1");
2067 ErasedTrackVectorPosition = VecPos;
2068 TrackEraseSuccessfulFlag =
true;
2069 ActiveElementErased =
true;
2072 FootCrossingErased =
true;
2079 unsigned int VecPos;
2080 InactiveTrackMapKeyPair.first = HLocInput;
2081 InactiveTrackMapKeyPair.second = VLocInput;
2086 VecPos = InactiveTrack2MultiMapIterator->second;
2091 if(ErrorString !=
"")
2093 throw Exception(ErrorString +
" for EraseTrackElement 2A");
2103 TrackEraseSuccessfulFlag =
true;
2104 InactiveElementErased =
true;
2124 VecPos = InactiveTrack2MultiMapIterator->second;
2129 if(ErrorString !=
"")
2131 throw Exception(ErrorString +
" for EraseTrackElement 2B");
2139 TrackEraseSuccessfulFlag =
true;
2140 InactiveElementErased =
true;
2157 bool TrackPlottedFlag =
false;
2158 if(ActiveElementErased && InactiveElementErased)
2160 if(!FootCrossingErased)
2170 ErasedTrackVectorPosition = -1;
2174 if(ActiveElementErased && FootCrossingErased)
2176 int NewSpeedTag = 1;
2177 if((TempTrackElement.
SpeedTag == 130) || (TempTrackElement.
SpeedTag == 146))
2189 ErasedTrackVectorPosition = -1;
2192 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
2194 if(PrefDirPos0 > -1)
2198 if(PrefDirPos1 > -1)
2202 if(PrefDirPos2 > -1)
2206 if(PrefDirPos3 > -1)
2212 if(TrackEraseSuccessfulFlag)
2229 void TTrack::PlotAndAddTrackElement(
int Caller,
int CurrentTag,
int Aspect,
int HLocInput,
int VLocInput,
bool &TrackPlottedFlag,
bool InternalChecks,
bool PerformNameSearch)
2236 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2237 bool PlatAllowedFlag =
false;
2239 TrackPlottedFlag =
false;
2251 LocationNameEntry.first =
"";
2259 TempTrackElement.
HLoc = HLocInput;
2260 TempTrackElement.
VLoc = VLocInput;
2286 else if(Aspect == 1)
2290 else if(Aspect == 2)
2294 else if(Aspect == 3)
2303 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2306 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2308 if(InactiveFoundFlag)
2312 NonStationOrLevelCrossingPresent =
true;
2316 NonStationOrLevelCrossingPresent =
true;
2320 PlatformPresent =
true;
2331 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2339 PlatAllowedFlag =
true;
2343 PlatAllowedFlag =
true;
2347 PlatAllowedFlag =
true;
2351 PlatAllowedFlag =
true;
2355 TrackPlottedFlag =
true;
2357 if(PerformNameSearch)
2386 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1048, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2387 (!FoundFlag && !InactiveFoundFlag))
2390 TrackPlottedFlag =
true;
2392 if(PerformNameSearch)
2425 TrackPlottedFlag =
true;
2437 else if(FoundFlag || InactiveFoundFlag)
2450 if(PerformNameSearch)
2459 bool BothPointFillets =
true;
2474 TrackPlottedFlag =
true;
2476 if(InternalChecks && PerformNameSearch)
2488 bool InternalChecks)
2492 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2493 bool PlatAllowedFlag =
false;
2495 TrackLinkingRequiredFlag =
false;
2498 LocationNameEntry.first =
"";
2504 TempTrackElement.
HLoc = HLocInput;
2505 TempTrackElement.
VLoc = VLocInput;
2506 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2507 for(
int x = 0; x < 4; x++)
2513 TempTrackElement.
Conn[x] = -1;
2527 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2529 if(InactiveFoundFlag)
2533 NonStationOrLevelCrossingPresent =
true;
2537 NonStationOrLevelCrossingPresent =
true;
2541 PlatformPresent =
true;
2552 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2560 PlatAllowedFlag =
true;
2564 PlatAllowedFlag =
true;
2568 PlatAllowedFlag =
true;
2572 PlatAllowedFlag =
true;
2576 TrackLinkingRequiredFlag =
true;
2607 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1055, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2608 (!FoundFlag && !InactiveFoundFlag))
2611 TrackLinkingRequiredFlag =
true;
2648 TrackLinkingRequiredFlag =
true;
2660 else if(FoundFlag || InactiveFoundFlag)
2679 bool BothPointFillets =
true;
2694 TrackLinkingRequiredFlag =
true;
2724 ShowMessage(
"Gaps must be set before track can be validated");
2734 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2745 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2762 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2769 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2793 std::pair<AnsiString, char>TempMapPair;
2801 TempMapPair.second =
'x';
2811 AnsiString Name =
"";
2812 typedef std::list<AnsiString> TNoPlatsList;
2813 TNoPlatsList::iterator NPLIt;
2814 TNoPlatsList NoPlatsList;
2815 typedef std::list<AnsiString> TLocNameList;
2816 TLocNameList LocNameList;
2821 LocNameList.push_back(LNMMIt->first);
2824 LocNameList.unique();
2825 for(TLocNameList::iterator LNLIt = LocNameList.begin(); LNLIt != LocNameList.end(); LNLIt++)
2829 if(MMRange.first == MMRange.second)
2835 if((LNMMIt->second) < 0)
2849 TempIt = MMRange.second;
2850 if(LNMMIt == --TempIt)
2852 NoPlatsList.push_back(Name);
2856 if(!NoPlatsList.empty())
2858 AnsiString NoPlatsAnsiList =
"";
2859 for(NPLIt = NoPlatsList.begin(); NPLIt != NoPlatsList.end(); NPLIt++)
2861 NoPlatsAnsiList += *NPLIt +
'\n';
2865 if(NoPlatsList.size() > 1)
2867 ShowMessage(
"Please note: the following locations have no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2871 ShowMessage(
"Please note: the following location has no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2886 int NewHLoc, NewVLoc;
2887 bool ConnectionFoundFlag, LinkFoundFlag;
2889 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2891 for(
unsigned int y = 0; y < 4; y++)
2909 ConnectionFoundFlag =
false;
2910 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2916 ConnectionFoundFlag =
true;
2918 LinkFoundFlag =
false;
2919 for(
unsigned int a = 0; a < 4; a++)
2923 LinkFoundFlag =
true;
2939 if(!ConnectionFoundFlag)
3014 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
3031 bool UnsetGaps =
false;
3038 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
3042 for(
unsigned int y = 0; y < 4; y++)
3054 for(
unsigned int y = 0; y < 4; y++)
3064 for(
unsigned int y = 1; y < 4; y++)
3073 for(
unsigned int y = 0; y < 4; y++)
3086 for(
unsigned int y = 0; y < 4; y++)
3114 int NumberOfActiveElements = 0;
3116 GraphicsFollow =
false;
3120 if(MarkerString[MarkerString.Length()] ==
'1')
3122 GraphicsFollow =
true;
3124 for(
int x = 0; x < NumberOfActiveElements; x++)
3130 TrackElement.
HLoc = TempInt;
3132 TrackElement.
VLoc = TempInt;
3138 TrackElement.
Conn[0] = TempInt;
3162 if((TempInt != -1) && (TempInt < 10))
3172 if((TempInt != -1) && (TempInt < 10))
3189 if(Marker[1] ==
'3')
3193 else if(Marker[1] ==
'2')
3197 else if(Marker[1] ==
'G')
3211 int NumberOfInactiveElements = 0;
3215 for(
int x = 0; x < NumberOfInactiveElements; x++)
3221 TrackElement.
HLoc = TempInt;
3223 TrackElement.
VLoc = TempInt;
3229 bool LocError =
false;
3258 for(
int x = 0; x < NumberOfGraphics; x++)
3269 bool FileError =
false;
3271 for(
int x = 0; x < NumberOfGraphics; x++)
3284 UGME.second =
new TPicture;
3285 UGME.second->LoadFromFile(
UGME.first);
3288 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
3295 catch(
const EInvalidGraphic &e)
3304 delete UGMIt->second;
3309 catch(
const Exception &e)
3318 delete UGMIt->second;
3326 bool FoundInMap =
false;
3345 UGME.second =
new TPicture;
3346 UGME.second->LoadFromFile(
UGME.first);
3349 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
3356 catch(
const EInvalidGraphic &e)
3365 delete UGMIt->second;
3370 catch(
const Exception &e)
3379 delete UGMIt->second;
3404 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
3408 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
3410 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
3413 VecFile << x <<
'\n';
3414 VecFile << TrackElement.
SpeedTag <<
'\n';
3415 VecFile << TrackElement.
HLoc <<
'\n';
3416 VecFile << TrackElement.
VLoc <<
'\n';
3420 VecFile << TrackElement.
Conn[0] <<
'\n';
3424 VecFile << TrackElement.
Attribute <<
'\n';
3430 VecFile << int(1) <<
'\n';
3434 VecFile << int(0) <<
'\n';
3437 VecFile << TrackElement.
Length01 <<
'\n';
3438 VecFile << TrackElement.
Length23 <<
'\n';
3441 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3448 VecFile <<
"3*****" <<
'\0' <<
'\n';
3452 VecFile <<
"2*****" <<
'\0' <<
'\n';
3456 VecFile <<
"G*****" <<
'\0' <<
'\n';
3460 VecFile <<
"4*****" <<
'\0' <<
'\n';
3465 VecFile <<
"******" <<
'\0' <<
'\n';
3470 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
3474 VecFile << x <<
'\n';
3475 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
3476 VecFile << InactiveTrackElement.
HLoc <<
'\n';
3477 VecFile << InactiveTrackElement.
VLoc <<
'\n';
3478 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3479 VecFile <<
"******" <<
'\0' <<
'\n';
3494 GraphicsFollow =
false;
3496 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
3502 AnsiString MarkerString;
3509 if(MarkerString[MarkerString.Length()] ==
'1')
3511 GraphicsFollow =
true;
3513 for(
int x = 0; x < NumberOfActiveElements; x++)
3521 int SpeedTag = TempInt;
3528 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3534 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3539 if((SpeedTag > 87) && (SpeedTag < 96))
3542 if((TempInt < -1) || (TempInt > 3))
3548 if((TempInt < -1) || (TempInt > 999999))
3554 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3555 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3558 if((TempInt < -1) || (TempInt > 5))
3564 if((SpeedTag >= 68) && (SpeedTag <= 75))
3567 if((TempInt != 0) && (TempInt != 1))
3574 if((TempInt < -1) || (TempInt > 999999))
3580 if((TempInt < -1) || (TempInt > 999999))
3586 if((TempInt < -1) || (TempInt > 999999))
3592 if((TempInt < -1) || (TempInt > 999999))
3613 int NumberOfInactiveElements = 0;
3616 if(NumberOfInactiveElements < 0)
3626 for(
int x = 0; x < NumberOfInactiveElements; x++)
3640 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3646 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3673 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3679 AnsiString FileName =
"", TempStr =
"";
3681 for(
int x = 0; x < NumberOfGraphics; x++)
3683 TPicture *TempPicture =
new TPicture;
3692 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3705 catch(
const EInvalidGraphic &e)
3710 for(
int y = x + 1; y < NumberOfGraphics; y++)
3716 ShowMessage(FileName +
3717 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3722 catch(
const Exception &e)
3727 for(
int y = x + 1; y < NumberOfGraphics; y++)
3733 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3734 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3752 for(
int x = 0; x < VecSize; x++)
3775 for(
int x = 0; x < VecSize; x++)
3797 for(
int x = 0; x < VecSize; x++)
3851 for(
int x = 0; x < VecSize; x++)
3908 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3960 if(BothPointFilletsAndBasicLCs)
4037 Bitmap->Canvas->CopyMode = cmSrcCopy;
4039 Graphics::TBitmap *GraphicOutput;
4214 for(
int x = 0; x < 40; x++)
4243 Graphics::TBitmap *GraphicPtr;
4258 Graphics::TBitmap* SignalPlatformGraphic;
4291 if(OldTransparentColour !=
clB5G5R5)
4314 Bitmap->Canvas->CopyMode = cmSrcCopy;
4342 Bitmap->Canvas->CopyMode = cmSrcCopy;
4344 Graphics::TBitmap *GraphicOutput;
4354 if(BaseElement == 1)
4450 for(
int x = 0; x < 40; x++)
4479 Graphics::TBitmap *GraphicPtr;
4494 Graphics::TBitmap* SignalPlatformGraphic;
4557 for(
int x = 0; x < 40; x++)
4565 Graphics::TBitmap* SignalPlatformGraphic;
4606 if(OldTransparentColour !=
clB5G5R5)
4620 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4692 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4706 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4732 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4757 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4787 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4821 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4858 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4876 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4897 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4929 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4936 throw Exception(
"Error - Map & Vector different sizes");
4938 unsigned int NonZeroCount = 0;
4940 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4949 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4955 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4959 TrackMapEntry.first = TrackMapKeyPair;
4960 TrackMapEntry.second = x;
4961 if(!(
TrackMap.insert(TrackMapEntry).second))
4963 throw Exception(
"Error - map insertion failure, TrackVector in error");
4967 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4969 for(
unsigned int y = 0; y < 4; y++)
4994 THVPair GapMapKeyPair, GapMapValuePair;
4997 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5003 GapMapEntry.first = GapMapKeyPair;
5006 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
5010 GapMapEntry.second = GapMapValuePair;
5013 GapMap.insert(GapMapEntry);
5028 bool TrackElementPositionsOK =
true;
5030 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5042 "Footbridge or underpass connection error. Each end must connect to a platform, concourse "
5043 "or other footbridge or underpass, and they can't connect to each other (i.e. a footbridge "
5044 "can't connect to an underpass or vice versa)");
5052 for(
unsigned int y = 0; y < 4; y++)
5070 bool ConnectionFoundFlag;
5074 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
5080 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
5089 if(ConnectionFoundFlag)
5094 bool ExitSignal =
false;
5105 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
5107 TrackElementPositionsOK =
false;
5112 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
5114 TrackElementPositionsOK =
false;
5119 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
5123 TrackElementPositionsOK =
false;
5128 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
5131 TrackElementPositionsOK =
false;
5143 ShowMessage(
"Bridge next to a signal - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
5146 TrackElementPositionsOK =
false;
5151 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
5152 TrackElementPositionsOK =
false;
5155 if(!TrackElementPositionsOK)
5162 throw Exception(
"Error in track element positions in FinalCall");
5175 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5181 for(
unsigned int y = 0; y < 4; y++)
5203 bool ConnectionFoundFlag;
5204 bool LinkMatchFound =
false;
5207 if(ConnectionFoundFlag)
5209 for(
unsigned int a = 0; a < 4; a++)
5215 LinkMatchFound =
true;
5226 throw Exception(
"Error in final track linkage - - no matching link found");
5239 throw Exception(
"Error in final track linkage - connection not found");
5255 bool ConnErrorFlag =
false;
5257 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5261 ConnErrorFlag =
true;
5265 ConnErrorFlag =
true;
5269 ConnErrorFlag =
true;
5273 ConnErrorFlag =
true;
5282 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5291 throw Exception(
"ConnError in LinkTrack - Final");
5295 throw Exception(
"ConnError in LinkTrack - Precheck");
5298 bool CLkErrorFlag =
false;
5300 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5304 CLkErrorFlag =
true;
5308 CLkErrorFlag =
true;
5312 CLkErrorFlag =
true;
5316 CLkErrorFlag =
true;
5324 throw Exception(
"CLkError in LinkTrack - Final");
5328 throw Exception(
"CLkError in LinkTrack - Precheck");
5333 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5363 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5379 for(
unsigned int y = 0; y < 4; y++)
5398 bool ConnectionFoundFlag;
5404 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
5413 if(ConnectionFoundFlag)
5416 bool LinkFoundFlag =
false;
5473 for(
unsigned int a = 0; a < 4; a++)
5482 LinkFoundFlag =
true;
5490 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
5500 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
5514 bool ConnErrorFlag =
false;
5516 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5520 ConnErrorFlag =
true;
5524 ConnErrorFlag =
true;
5528 ConnErrorFlag =
true;
5532 ConnErrorFlag =
true;
5541 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5550 throw Exception(
"ConnError in LinkTrack - Final");
5554 throw Exception(
"ConnError in LinkTrack - Precheck");
5557 bool CLkErrorFlag =
false;
5559 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5563 CLkErrorFlag =
true;
5567 CLkErrorFlag =
true;
5571 CLkErrorFlag =
true;
5575 CLkErrorFlag =
true;
5583 throw Exception(
"CLkError in LinkTrack - Final");
5587 throw Exception(
"CLkError in LinkTrack - Precheck");
5591 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5620 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5636 for(
unsigned int y = 0; y < 4; y++)
5655 bool ConnectionFoundFlag =
false;
5657 if(ConnectionFoundFlag)
5661 bool LinkFoundFlag =
false;
5681 for(
unsigned int a = 0; a < 4; a++)
5690 LinkFoundFlag =
true;
5710 bool ConnErrorFlag =
false;
5712 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5716 ConnErrorFlag =
true;
5720 ConnErrorFlag =
true;
5724 ConnErrorFlag =
true;
5728 ConnErrorFlag =
true;
5736 bool CLkErrorFlag =
false;
5738 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5742 CLkErrorFlag =
true;
5746 CLkErrorFlag =
true;
5750 CLkErrorFlag =
true;
5754 CLkErrorFlag =
true;
5772 int Position1, Position2;
5778 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
5780 int HLoc1 = GapMapPtr->first.first;
5781 int VLoc1 = GapMapPtr->first.second;
5782 int HLoc2 = GapMapPtr->second.first;
5783 int VLoc2 = GapMapPtr->second.second;
5786 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
5790 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
5794 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
5798 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
5816 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
5817 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5827 bool FoundFlag =
false;
5839 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5840 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5841 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5870 bool FoundFlag =
false;
5883 TrackMapKeyPair.first = TrackElement.
HLoc;
5884 TrackMapKeyPair.second = TrackElement.
VLoc;
5885 TrackMapEntry.first = TrackMapKeyPair;
5890 LocationNameEntry.second = -(int)(
TrackVector.size());
5930 TrackMapKeyPair.first = HLoc;
5931 TrackMapKeyPair.second = VLoc;
5932 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5942 return(TrackMapPtr->second);
5955 TrackMapKeyPair.first = HLoc;
5956 TrackMapKeyPair.second = VLoc;
5957 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5960 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5961 throw Exception(Message);
5979 MapKeyPair.first = HLoc;
5980 MapKeyPair.second = VLoc;
5981 MapPtr = Map.find(MapKeyPair);
5982 if(MapPtr == Map.end())
5984 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc) +
" in GetTrackElementFromAnyTrackMap";
5985 throw Exception(Message);
5990 return(Vector.at(MapPtr->second));
6000 THVPair InactiveTrackMapKeyPair;
6003 InactiveTrackMapKeyPair.first = HLoc;
6004 InactiveTrackMapKeyPair.second = VLoc;
6008 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
6009 throw Exception(Message);
6023 bool Present =
true;
6027 TrackMapKeyPair.first = HLoc;
6028 TrackMapKeyPair.second = VLoc;
6029 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6044 bool Present =
true;
6045 THVPair InactiveTrackMapKeyPair;
6048 InactiveTrackMapKeyPair.first = HLoc;
6049 InactiveTrackMapKeyPair.second = VLoc;
6067 THVPair InactiveTrackMapKeyPair;
6072 InactiveTrackMapKeyPair.first = HLoc;
6073 InactiveTrackMapKeyPair.second = VLoc;
6082 if(InactiveTrackRange.first == InactiveTrackRange.second)
6091 RetPair.first = InactiveTrackRange.first->second;
6092 RetPair.second = (--InactiveTrackRange.second)->second;
6105 AnsiString(DivergingPosition));
6116 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
6117 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
6118 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
6119 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
6120 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
6121 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
6122 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
6123 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
6124 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
6125 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
6126 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
6127 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
6161 throw Exception(
"Error, Wrong track type in PlotGap");
6163 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
6167 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
6171 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
6175 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
6179 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
6183 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
6187 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
6191 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
6195 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
6199 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
6203 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
6207 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
6211 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
6215 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
6219 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
6223 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
6239 PosPair.first = TrackElement.
HLoc;
6240 PosPair.second = TrackElement.
VLoc;
6244 Disp->
PlotOutput(283, TrackElement.
HLoc * 16, TrackElement.
VLoc * 16, MOMIt->second);
6257 throw Exception(
"Error, Wrong track type in PlotPoints");
6261 bool FoundFlag =
false;
6263 if(IMPair.first > 0)
6279 else if(TrackElement.
SpeedTag < 132)
6290 else if(!TrackElement.
Failed)
6297 else if(TrackElement.
SpeedTag < 132)
6315 else if(TrackElement.
SpeedTag < 132)
6329 bool BlueLoc =
false;
6338 if(FoundFlag && !BlueLoc)
6353 bool FoundFlag =
false;
6356 throw Exception(
"Error, Wrong track type in PlotSignal");
6360 for(
int x = 0; x < 40; x++)
6443 for(
int x = 0; x < 40; x++)
6450 Graphics::TBitmap* SignalPlatformGraphic;
6452 if(IMPair.first > 0)
6474 for(
int x = 0; x < 8; x++)
6481 if(IMPair.first > 0)
6498 for(
int x = 0; x < 8; x++)
6505 if(IMPair.first > 0)
6598 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
6606 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
6614 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
6622 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
6638 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
6646 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
6654 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
6662 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
6695 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
6707 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
6719 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
6731 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
6773 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
6775 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6777 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
6780 if(BaseElementSpeedTag == 1)
6784 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
6791 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
6799 Graphics::TBitmap *RouteGraphic;
6801 if(TypeOfRoute == 1)
6805 else if(TypeOfRoute == 0)
6811 RouteGraphic = BaseGraphic;
6818 if(UpStep == DownStep)
6821 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
6831 else if((DownStep - UpStep) == 1)
6836 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6846 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6859 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6869 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6885 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6895 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6905 else if(DownStep == 0)
6908 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6918 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6931 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6941 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6951 for(
int x = (UpStep + 1); x < DownStep; x++)
6956 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
6960 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
6981 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
6988 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
6994 Graphics::TBitmap *RouteGraphic;
6996 if(TypeOfRoute == 1)
7000 else if(TypeOfRoute == 0)
7006 RouteGraphic = BaseGraphic;
7015 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
7025 else if((RStep - LStep) == 1)
7030 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
7040 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
7053 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
7063 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
7079 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
7089 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
7102 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
7112 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
7125 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
7135 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
7145 for(
int x = (LStep + 1); x < RStep; x++)
7150 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
7154 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
7178 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7181 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7183 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7185 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7188 if(BaseElementSpeedTag == 1)
7192 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
7199 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
7205 if(UpStep == DownStep)
7216 else if((DownStep - UpStep) == 1)
7235 for(
int x = (UpStep + 1); x < DownStep; x++)
7244 for(
int x = (UpStep + 1); x < DownStep; x++)
7251 for(
int x = UpStep; x <= DownStep; x++)
7264 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
7271 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
7288 else if((RStep - LStep) == 1)
7307 for(
int x = (LStep + 1); x < RStep; x++)
7316 for(
int x = (LStep + 1); x < RStep; x++)
7323 for(
int x = LStep; x <= RStep; x++)
7342 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
7344 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7346 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
7349 if(BaseElementSpeedTag == 1)
7353 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
7360 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
7366 for(
int x = UpStep; x < (DownStep + 1); x++)
7381 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
7388 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
7394 for(
int x = LStep; x < (RStep + 1); x++)
7413 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7416 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7418 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7420 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7425 if(BaseElementSpeedTag == 1)
7429 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
7436 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
7442 for(
int x = UpStep; x <= DownStep; x++)
7456 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
7463 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
7469 for(
int x = LStep; x <= RStep; x++)
7485 Graphics::TBitmap *RouteGraphic;
7488 if(BaseElementSpeedTag == 1)
7490 if(TypeOfRoute == 1)
7494 else if(TypeOfRoute == 0)
7500 RouteGraphic = BaseGraphic;
7504 RouteGraphic = BaseGraphic;
7510 if(TypeOfRoute == 1)
7514 else if(TypeOfRoute == 0)
7520 RouteGraphic = BaseGraphic;
7524 RouteGraphic = BaseGraphic;
7529 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
7534 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
7538 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
7545 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
7548 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
7553 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
7558 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
7562 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
7569 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
7572 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
7697 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7701 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7732 "," + AnsiString(VLoc));
7736 int DummyRouteNumber;
7738 TrainPresent =
false;
7742 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
7744 TrackMapKeyPair.first = HLoc;
7745 TrackMapKeyPair.second = VLoc + UpStep;
7746 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7755 TrainPresent =
true;
7769 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
7771 TrackMapKeyPair.first = HLoc;
7772 TrackMapKeyPair.second = VLoc + DownStep;
7773 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7782 TrainPresent =
true;
7796 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
7798 TrackMapKeyPair.first = HLoc + LeftStep;
7799 TrackMapKeyPair.second = VLoc;
7800 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7809 TrainPresent =
true;
7823 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
7825 TrackMapKeyPair.first = HLoc + RightStep;
7826 TrackMapKeyPair.second = VLoc;
7827 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7836 TrainPresent =
true;
7856 for(
unsigned int x = 0; x < SearchVector.size(); x++)
7873 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7876 throw Exception(
"PlotSmallFlashingLinkedLevelCrossings");
7882 while(
IsLCAtHV(61, HLoc, (VLoc + UpStep)))
7889 while(
IsLCAtHV(62, HLoc, (VLoc + DownStep)))
7895 for(
int x = UpStep; x <= DownStep; x++)
7902 while(
IsLCAtHV(63, (HLoc + LStep), VLoc))
7909 while(
IsLCAtHV(64, (HLoc + RStep), VLoc))
7915 for(
int x = LStep; x <= RStep; x++)
7931 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
7938 else if(TrackElement.
SpeedTag < 132)
7956 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7973 AnsiString(ScreenPosV));
7988 AnsiString(ScreenPosV));
7999 AnsiString(VPosTrue));
8013 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
8025 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
8026 " in TrackMap, Caller=" + (AnsiString)Caller);
8028 if(MapVecPos != (
int)a)
8030 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
8031 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
8032 (AnsiString)Caller);
8038 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
8039 " Caller=" + (AnsiString)Caller);
8059 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
8060 " in InactiveMap, Caller=" + (AnsiString)Caller);
8062 if((InactivePair.first != a) && (InactivePair.second != a))
8064 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
8065 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
8066 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
8071 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
8072 " Caller=" + (AnsiString)Caller);
8082 int Position1, Position2;
8088 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
8090 int HLoc1 = GapMapPtr->first.first;
8091 int VLoc1 = GapMapPtr->first.second;
8092 int HLoc2 = GapMapPtr->second.first;
8093 int VLoc2 = GapMapPtr->second.second;
8096 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
8100 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
8104 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
8108 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
8112 unsigned int GapCount = 0;
8114 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
8122 if((
GapMap.size() * 2) != GapCount)
8124 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
8125 (AnsiString)Caller);
8135 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
8139 throw Exception(
"Error - TrackFinished with erase element still present");
8144 AnsiString IDString;
8146 if(TrackElement.
HLoc < 0)
8148 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
8152 IDString = AnsiString(TrackElement.
HLoc) +
"-";
8154 if(TrackElement.
VLoc < 0)
8156 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
8160 IDString += AnsiString(TrackElement.
VLoc);
8175 for(
int x = 1; x < String.Length() + 1; x++)
8177 if(String.IsDelimiter(
"-", x))
8182 if(x == String.Length())
8186 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
8196 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
8201 if(DelimPos == String.Length())
8205 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
8210 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
8214 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
8221 if(String.SubString(1, 1) !=
"N")
8223 for(
int x = 1; x < DelimPos; x++)
8225 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8229 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8236 if(String.SubString(1, 1) ==
"N")
8238 for(
int x = 2; x < DelimPos; x++)
8240 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8244 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8251 if(String.SubString(1, 1) ==
"N")
8253 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
8257 HLoc = String.SubString(1, DelimPos - 1).ToInt();
8259 if(String.SubString(DelimPos + 1, 1) !=
"N")
8261 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
8263 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8267 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8274 if(String.SubString(DelimPos + 1, 1) ==
"N")
8276 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
8278 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8282 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8289 if(String.SubString(DelimPos + 1, 1) ==
"N")
8291 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
8295 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
8300 TrackMapPtr =
TrackMap.find(HVPair);
8305 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
8311 return(TrackMapPtr->second);
8313 catch(
const Exception &e)
8316 ShowMessage(
"Syntax error in track element identifier: <" + String +
">");
8330 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
8331 int HLoc = TrackElement.
HLoc;
8332 int VLoc = TrackElement.
VLoc;
8435 AnsiString(SpeedTag));
8446 if(HVRange.first == HVRange.second)
8453 HVIt1 = HVRange.first;
8458 if(--HVRange.second != HVRange.first)
8460 HVIt2 = HVRange.second;
8464 HVIt2->second).
SpeedTag == SpeedTag)))
8484 AnsiString(SpeedTag));
8550 AnsiString TestString1, TestString2;
8555 throw Exception(
"LNPendingList size not 1 on entry");
8557 int CurrentElementNumber;
8558 bool FoundFlag =
false, ErasedFlag =
false;
8564 int H = CurrentElement->HLoc;
8565 int V = CurrentElement->VLoc;
8566 int Tag = CurrentElement->SpeedTag;
8572 for(
int x = 0; x < 25; x++)
8582 for(
int x = 0; x < 25; x++)
8592 for(
int x = 0; x < 25; x++)
8602 for(
int x = 0; x < 25; x++)
8612 for(
int x = 0; x < 28; x++)
8622 for(
int x = 0; x < 8; x++)
8632 for(
int x = 0; x < 8; x++)
8642 for(
int x = 0; x < 4; x++)
8658 bool FoundFlag2 =
false;
8676 for(
int x = 0; x < 8; x++)
8686 for(
int x = 0; x < 8; x++)
8699 if(CurrentElementNumber > -1)
8704 if((ExistingName !=
"") && (ExistingName != LocationName))
8720 AddName(1, CurrentElement, LocationName);
8724 LNDone2MultiMapEntry.first = HVPair;
8736 if(SNRange.first != SNRange.second)
8740 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
8747 TVIt->LocationName =
"";
8748 TVIt->ActiveTrackElementName =
"";
8782 std::pair<AnsiString, char>TempMapPair;
8790 TempMapPair.second =
'x';
8808 AnsiString(SpeedTag));
8818 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
8825 int MapPos = -1 - Position;
8829 FoundElement = MapPos;
8845 FoundElement = IMPair.first;
8854 FoundElement = IMPair.second;
8875 AnsiString OldName = TrackElement->LocationName, ErrorString;
8877 TrackElement->LocationName = Name;
8878 int HLoc = TrackElement->HLoc;
8879 int VLoc = TrackElement->VLoc;
8893 if(ErrorString !=
"")
8895 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
8919 if(LNDone2MultiMapIterator->second == MapPos)
8946 if(*LNPendingListIterator == MapPos)
9019 if(NameBeingChecked !=
"")
9025 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
9033 NameBeingChecked = LNMMRg.second->first;
9035 if(NameBeingChecked !=
"")
9041 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
9062 if(LNMMIt->second < 0)
9072 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
9080 std::list<THVPair> HVLinkedList;
9083 HVPairsLinkedMap.begin()->second =
true;
9084 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
9087 THVPair HVPairUnderExamination;
9088 THVPairsLinkedMap::iterator HVPLMIt;
9090 while(!HVLinkedList.empty())
9092 HVPairUnderExamination = HVLinkedList.front();
9093 HVLinkedList.pop_front();
9094 HVPairNew.first = HVPairUnderExamination.first;
9095 HVPairNew.second = HVPairUnderExamination.second - 1;
9096 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9097 if(HVPLMIt != HVPairsLinkedMap.end())
9099 if(!HVPLMIt->second)
9101 HVLinkedList.push_back(HVPLMIt->first);
9103 HVPLMIt->second =
true;
9105 HVPairNew.first = HVPairUnderExamination.first - 1;
9106 HVPairNew.second = HVPairUnderExamination.second;
9107 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9108 if(HVPLMIt != HVPairsLinkedMap.end())
9110 if(!HVPLMIt->second)
9112 HVLinkedList.push_back(HVPLMIt->first);
9114 HVPLMIt->second =
true;
9116 HVPairNew.first = HVPairUnderExamination.first;
9117 HVPairNew.second = HVPairUnderExamination.second + 1;
9118 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9119 if(HVPLMIt != HVPairsLinkedMap.end())
9121 if(!HVPLMIt->second)
9123 HVLinkedList.push_back(HVPLMIt->first);
9125 HVPLMIt->second =
true;
9127 HVPairNew.first = HVPairUnderExamination.first + 1;
9128 HVPairNew.second = HVPairUnderExamination.second;
9129 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
9130 if(HVPLMIt != HVPairsLinkedMap.end())
9132 if(!HVPLMIt->second)
9134 HVLinkedList.push_back(HVPLMIt->first);
9136 HVPLMIt->second =
true;
9141 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
9143 if(!HVPLMIt->second)
9162 if(LocationName ==
"")
9173 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9180 ActiveTrackElementNameMapEntry.second = 0;
9202 bool FoundFlag, ErasedFlag =
false;
9206 if(SNRange.first != SNRange.second)
9209 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9212 TVIt->LocationName =
"";
9213 TVIt->ActiveTrackElementName =
"";
9247 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
9249 AnsiString LocationName;
9258 if(LocationName !=
"")
9266 if(LocationName !=
"")
9280 if(LocationName !=
"")
9282 int ModifiedPosition = -1 - Position;
9291 for(
int x = 0; x < 25; x++)
9301 else if(SpeedTag == 77)
9303 for(
int x = 0; x < 25; x++)
9313 else if(SpeedTag == 78)
9315 for(
int x = 0; x < 25; x++)
9325 else if(SpeedTag == 79)
9327 for(
int x = 0; x < 25; x++)
9337 else if(SpeedTag == 96)
9339 for(
int x = 0; x < 28; x++)
9349 else if(SpeedTag == 129)
9351 for(
int x = 0; x < 8; x++)
9361 else if(SpeedTag == 130)
9363 for(
int x = 0; x < 8; x++)
9373 else if(SpeedTag == 145)
9375 for(
int x = 0; x < 8; x++)
9385 else if(SpeedTag == 146)
9387 for(
int x = 0; x < 8; x++)
9397 else if(SpeedTag == 131)
9399 for(
int x = 0; x < 4; x++)
9419 bool FoundFlag2 =
false;
9446 AnsiString(SpeedTag));
9458 if(TempElement->LocationName !=
"")
9460 LocationName = TempElement->LocationName;
9461 FoundElement = IMPair.first;
9469 if(TempElement->LocationName !=
"")
9471 LocationName = TempElement->LocationName;
9472 FoundElement = IMPair.second;
9484 if(TempElement->LocationName !=
"")
9486 LocationName = TempElement->LocationName;
9487 FoundElement = -1 - Position;
9503 unsigned int Count = 0;
9510 AnsiString SName, TName, ErrorString;
9512 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9518 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
9519 AnsiString(Caller));
9532 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
9533 AnsiString(Caller));
9540 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
9541 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9546 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9552 if(ErrorString !=
"")
9554 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
9556 if(SNIt->second != -1 - (
int)x)
9558 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9559 AnsiString(Caller));
9565 bool FoundFlag =
false;
9574 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackElementAt(1369, x).HLoc) +
" & V " +
9575 AnsiString(
TrackElementAt(1370, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9579 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackElementAt(1371, x).HLoc) +
9580 " & V " + AnsiString(
TrackElementAt(1372, x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
9581 AnsiString(Caller));
9586 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackElementAt(1373, x).HLoc) +
" & V " +
9587 AnsiString(
TrackElementAt(1374, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9597 if(ErrorString !=
"")
9599 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
9601 if(SNIt->second != (
int)x)
9603 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9604 AnsiString(Caller));
9614 AnsiString &ErrorString)
9622 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
9624 bool FoundFlag =
false;
9628 if(SNRange.first == SNRange.second)
9630 ErrorString =
"Error, Name " + LocationName +
" not found in map";
9632 return(SNRange.first);
9636 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9638 if(SNIterator->second < 0)
9640 int TVPos = -1 - SNIterator->second;
9642 if(TVIt == TrackElement)
9651 int ITVPos = SNIterator->second;
9653 if(ITVIt == TrackElement)
9664 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
9681 LocationNameEntry.first = NewName;
9682 LocationNameEntry.second = SNIterator->second;
9696 int TruePos = -1 - Position;
9700 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9710 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9733 InactiveTrack2MultiMapIterator++)
9735 if(InactiveTrack2MultiMapIterator->second > VecPos)
9737 InactiveTrack2MultiMapIterator->second--;
9745 LocationNameMultiMapIterator++)
9747 if(LocationNameMultiMapIterator->second < 0)
9751 if(LocationNameMultiMapIterator->second > (
int)VecPos)
9753 LocationNameMultiMapIterator->second--;
9775 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
9777 if(TrackMapIterator->second > VecPos)
9779 TrackMapIterator->second--;
9787 LocationNameMultiMapIterator++)
9789 if(LocationNameMultiMapIterator->second >= 0)
9795 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
9797 LocationNameMultiMapIterator->second++;
9801 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9807 if(TkEl.
Conn[0] ==
int(VecPos))
9812 if(TkEl.
Conn[0] >
int(VecPos))
9816 if(TkEl.
Conn[0] > -1)
9844 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
9850 LocationNameEntry.second = -1 - TVPos;
9861 LocationNameEntry.second = ITVPos;
9903 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9935 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9956 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9982 AnsiString((
short)FirstTrack));
9984 int EXArray[16][2] =
9986 {2, 4}, {6, 2}, {8, 6}, {4, 8},
9987 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
9990 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
9991 Graphics::TBitmap *Bitmap;
9997 InLink = TrackElement.
Link[0];
9998 OutLink = TrackElement.
Link[1];
10004 InLink = TrackElement.
Link[2];
10005 OutLink = TrackElement.
Link[3];
10009 for(
int x = 0; x < 16; x++)
10011 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
10018 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLengthandSpeed");
10039 else if(TrackElement.
SpeedTag == 54)
10043 else if(TrackElement.
SpeedTag == 55)
10048 else if(Index == 0)
10054 else if(TrackElement.
SpeedTag == 58)
10058 else if(TrackElement.
SpeedTag == 59)
10063 else if(Index == 14)
10069 else if(TrackElement.
SpeedTag == 52)
10073 else if(TrackElement.
SpeedTag == 57)
10078 else if(Index == 15)
10084 else if(TrackElement.
SpeedTag == 53)
10088 else if(TrackElement.
SpeedTag == 56)
10170 TRect Rect(0,0,16,16);
10174 int Red, Green, Blue;
10175 int *R = &Red, *G = &Green, *B = &Blue;
10189 Col = TColor((65536 * Blue) + (256 * Green) + Red);
10203 Col = TColor((65536 * Blue) + (256 * Green) + Red);
10227 AnsiString((
short)FirstTrack));
10228 bool LengthDifferent =
false, SpeedDifferent =
false;
10235 int EXArray[16][2] =
10237 {2, 4}, {6, 2}, {8, 6}, {4, 8},
10238 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
10241 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
10242 Graphics::TBitmap *Bitmap;
10246 InLink = TrackElement.
Link[0];
10247 OutLink = TrackElement.
Link[1];
10251 InLink = TrackElement.
Link[2];
10252 OutLink = TrackElement.
Link[3];
10254 for(
int x = 0; x < 16; x++)
10256 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
10263 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLengthandSpeed");
10283 else if(TrackElement.
SpeedTag == 54)
10287 else if(TrackElement.
SpeedTag == 55)
10292 else if(Index == 0)
10298 else if(TrackElement.
SpeedTag == 58)
10302 else if(TrackElement.
SpeedTag == 59)
10307 else if(Index == 14)
10313 else if(TrackElement.
SpeedTag == 52)
10317 else if(TrackElement.
SpeedTag == 57)
10322 else if(Index == 15)
10328 else if(TrackElement.
SpeedTag == 53)
10332 else if(TrackElement.
SpeedTag == 56)
10346 if(LengthDifferent && SpeedDifferent)
10414 else if(LengthDifferent && !SpeedDifferent)
10561 AnsiString((
short)FirstTrack));
10562 LengthDifferent =
false;
10563 SpeedDifferent =
false;
10568 LengthDifferent =
true;
10572 SpeedDifferent =
true;
10574 if(LengthDifferent || SpeedDifferent)
10587 LengthDifferent =
true;
10591 SpeedDifferent =
true;
10593 if(LengthDifferent || SpeedDifferent)
10606 LengthDifferent =
true;
10610 SpeedDifferent =
true;
10612 if(LengthDifferent || SpeedDifferent)
10692 AnsiString TempName;
10693 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
10694 bool ForwardSet, ReverseSet;
10696 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10701 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10706 ForwardSet =
false;
10707 ReverseSet =
false;
10741 for(
int y = 0; y < 2; y++)
10772 StartElement = TempElement;
10773 StartVecPos = VecPos;
10776 EntryPos = 1 - Dir;
10777 StartEntryPos = 1 - Dir;
10785 VecPos = TempElement.
Conn[1 - EntryPos];
10786 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10788 EntryPos = TempEntryPos;
10809 ForwardNumber = ((Count + 1) / 2) + 1;
10810 ReverseNumber = (Count - ForwardNumber) + 1;
10812 EntryPos = 1 - Dir;
10813 TempElement = StartElement;
10814 VecPos = StartVecPos;
10815 if(Count == ForwardNumber)
10820 if(Count == ReverseNumber)
10828 VecPos = TempElement.
Conn[1 - EntryPos];
10829 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10831 EntryPos = TempEntryPos;
10833 if(Count == ForwardNumber)
10838 if(Count == ReverseNumber)
10851 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10880 AnsiString TempName;
10881 std::list<unsigned int> NameList;
10882 std::list<AnsiString> ContinuationNameList;
10883 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10889 ContinuationNameList.push_back(
TrackElementAt(1597, x).ActiveTrackElementName);
10892 ContinuationNameList.sort();
10893 ContinuationNameList.unique();
10895 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10900 bool NameIsAContinuation =
false;
10901 if(std::find(ContinuationNameList.begin(), ContinuationNameList.end(), TempElement.
ActiveTrackElementName) != ContinuationNameList.end())
10903 NameIsAContinuation =
true;
10916 if(((TempElement.
Conn[2] > -1)) && (TempElement.
Conn[3] > -1) &&
10924 NameList.push_back(x);
10929 if((TempElement.
Conn[2] > -1) && (TempElement.
Conn[3] > -1) &&
10937 NameList.push_back(x);
10947 NameList.push_back(x);
10950 while(!NameList.empty())
10952 unsigned int a = NameList.front();
10953 NameList.pop_front();
11111 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
11167 if((TextH / 16) - 1 <
HLocMin)
11171 if((TextH / 16) + 1 >
HLocMax)
11175 if((TextV / 16) - 1 <
VLocMin)
11179 if((TextV / 16) + 1 >
VLocMax)
11209 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
11210 bool &UserGraphicFoundFlag)
11213 TUserGraphicVector::iterator UserGraphicPtr;
11215 UserGraphicFoundFlag =
false;
11222 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
11223 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
11225 UserGraphicItem = x;
11226 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
11227 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
11228 UserGraphicFoundFlag =
true;
11246 int SpeedTag = TrackElement.
SpeedTag;
11250 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
11299 return(GraphicOutput);
11307 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
11310 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
11323 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
11324 " in InactiveTrackElementAt");
11335 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
11337 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
11362 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
11363 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
11367 if(SNRange.first == SNRange.second)
11372 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
11374 if(SNIterator->second < 0)
11388 HVPair.first = InactiveElement.
HLoc;
11389 HVPair.second = InactiveElement.
VLoc;
11393 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneStationLongEnoughForSplit (1)");
11395 int TVPos =
TrackMap.find(HVPair)->second;
11398 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
11404 FirstNamedExitPos = 0;
11406 SecondNamedElement =
TrackElementAt(561, FirstNamedElement.
Conn[FirstNamedExitPos]);
11408 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
11409 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
11412 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11414 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
11415 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
11416 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
11419 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
11429 FirstNamedExitPos = 1;
11431 SecondNamedElement =
TrackElementAt(564, FirstNamedElement.
Conn[FirstNamedExitPos]);
11433 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
11434 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
11437 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11439 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
11440 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
11441 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
11444 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
11470 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
11471 int FirstNamedExitPos, SecondNamedEntryPos, SecondNamedExitPos;
11475 if(SNRange.first == SNRange.second)
11480 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
11482 if(SNIterator->second < 0)
11496 HVPair.first = InactiveElement.
HLoc;
11497 HVPair.second = InactiveElement.
VLoc;
11500 throw Exception (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNonStationLongEnoughForSplit(1)");
11502 int TVPos =
TrackMap.find(HVPair)->second;
11505 if(((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1)) && ((FirstNamedElement.
Conn[2] == -1) || (FirstNamedElement.
Conn[3] == -1)))
11510 if((FirstNamedElement.
Conn[2] == -1) || (FirstNamedElement.
Conn[3] == -1))
11512 FirstNamedExitPos = 0;
11514 SecondNamedElement =
TrackElementAt(1611, FirstNamedElement.
Conn[FirstNamedExitPos]);
11517 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11518 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11520 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11522 else if(SecondNamedEntryPos == 2)
11524 SecondNamedExitPos = 3;
11526 else if(SecondNamedEntryPos == 3)
11528 SecondNamedExitPos = 2;
11530 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11537 FirstNamedExitPos = 1;
11539 SecondNamedElement =
TrackElementAt(1612, FirstNamedElement.
Conn[FirstNamedExitPos]);
11542 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11543 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11545 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11547 else if(SecondNamedEntryPos == 2)
11549 SecondNamedExitPos = 3;
11551 else if(SecondNamedEntryPos == 3)
11553 SecondNamedExitPos = 2;
11555 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11563 else if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
11565 FirstNamedExitPos = 2;
11567 SecondNamedElement =
TrackElementAt(1613, FirstNamedElement.
Conn[FirstNamedExitPos]);
11570 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11571 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11573 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11575 else if(SecondNamedEntryPos == 2)
11577 SecondNamedExitPos = 3;
11579 else if(SecondNamedEntryPos == 3)
11581 SecondNamedExitPos = 2;
11583 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11590 FirstNamedExitPos = 3;
11592 SecondNamedElement =
TrackElementAt(1614, FirstNamedElement.
Conn[FirstNamedExitPos]);
11595 SecondNamedEntryPos = FirstNamedElement.
ConnLinkPos[FirstNamedExitPos];
11596 if((SecondNamedEntryPos == 0) || (SecondNamedEntryPos == 1))
11598 SecondNamedExitPos = 1 - SecondNamedEntryPos;
11600 else if(SecondNamedEntryPos == 2)
11602 SecondNamedExitPos = 3;
11604 else if(SecondNamedEntryPos == 3)
11606 SecondNamedExitPos = 2;
11608 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
11625 int MidEntryPos,
int &FrontTrainFrontPos,
int &FrontTrainRearPos,
int &RearTrainFrontPos,
int &RearTrainRearPos,
bool &TemporaryDelay)
11633 LocationName + AnsiString(LeadElement) +
"," + AnsiString(LeadExitPos) +
"," + AnsiString(MidElement) +
"," + AnsiString(MidEntryPos));
11635 TemporaryDelay =
false;
11637 int FwdPos[3] = {LeadElement, -1, -1};
11638 int RwdPos[3] = {MidElement, -1, -1};
11641 int FwdPos1EntryPos, FwdPos1ExitPos, FwdPos2EntryPos, FwdPos2ExitPos, RwdPos1EntryPos, RwdPos1ExitPos, RwdPos2EntryPos, RwdPos2ExitPos;
11643 bool FwdDerail1 =
false, FwdDerail2 =
false, RwdDerail1 =
false, RwdDerail2 =
false;
11644 int NumFwdNamedElements = 0, NumFwdElements = 0, NumRwdNamedElements = 0, NumRwdElements = 1;
11647 NumRwdNamedElements = 1;
11650 FwdPos[1] = FwdPos0Element.
Conn[LeadExitPos];
11653 NumFwdElements = 1;
11657 NumFwdNamedElements = 1;
11659 FwdPos1EntryPos = FwdPos0Element.
ConnLinkPos[LeadExitPos];
11661 FwdPos[2] = FwdPos1Element.
Conn[FwdPos1ExitPos];
11664 NumFwdElements = 2;
11665 FwdPos2EntryPos = FwdPos1Element.
ConnLinkPos[FwdPos1ExitPos];
11670 NumFwdNamedElements = 2;
11676 RwdPos[1] = RwdPos0Element.
Conn[MidEntryPos];
11679 NumRwdElements = 2;
11683 NumRwdNamedElements = 2;
11685 RwdPos1ExitPos = RwdPos0Element.
ConnLinkPos[MidEntryPos];
11687 RwdPos[2] = RwdPos1Element.
Conn[RwdPos1EntryPos];
11690 NumRwdElements = 3;
11691 RwdPos2ExitPos = RwdPos1Element.
ConnLinkPos[RwdPos1EntryPos];
11696 NumRwdNamedElements = 3;
11703 if(NumFwdNamedElements == 2)
11705 FrontTrainFrontPos = FwdPos[2];
11706 FrontTrainRearPos = FwdPos[1];
11707 RearTrainFrontPos = LeadElement;
11708 RearTrainRearPos = MidElement;
11709 if(FwdDerail1 || FwdDerail2)
11711 TrainController->
StopTTClockMessage(159, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11712 TemporaryDelay =
true;
11718 TrainController->
StopTTClockMessage(160, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11719 TemporaryDelay =
true;
11725 TrainController->
StopTTClockMessage(161, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11726 TemporaryDelay =
true;
11734 else if((NumFwdNamedElements == 1) && (NumRwdNamedElements >= 1) && (NumRwdElements >= 2))
11736 FrontTrainFrontPos = FwdPos[1];
11737 FrontTrainRearPos = LeadElement;
11738 RearTrainFrontPos = MidElement;
11739 RearTrainRearPos = RwdPos[1];
11742 TrainController->
StopTTClockMessage(162, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11743 TemporaryDelay =
true;
11749 TrainController->
StopTTClockMessage(163, HeadCode +
" unable to split at " + LocationName +
", points set wrongly behind train. Please change these points to allow the split.");
11750 TemporaryDelay =
true;
11756 TrainController->
StopTTClockMessage(164, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11757 TemporaryDelay =
true;
11763 TrainController->
StopTTClockMessage(165, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11764 TemporaryDelay =
true;
11772 else if((NumRwdNamedElements >= 2) && (NumRwdElements == 3))
11774 FrontTrainFrontPos = LeadElement;
11775 FrontTrainRearPos = MidElement;
11776 RearTrainFrontPos = RwdPos[1];
11777 RearTrainRearPos = RwdPos[2];
11778 if(RwdDerail1 || RwdDerail2)
11780 TrainController->
StopTTClockMessage(166, HeadCode +
" unable to split at " + LocationName +
", points set wrongly behind train. Please change these points to allow the split.");
11781 TemporaryDelay =
true;
11787 TrainController->
StopTTClockMessage(167, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11788 TemporaryDelay =
true;
11794 TrainController->
StopTTClockMessage(168, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11795 TemporaryDelay =
true;
11804 else if((NumFwdNamedElements == 1) && (NumFwdElements == 2))
11806 FrontTrainFrontPos = FwdPos[2];
11807 FrontTrainRearPos = FwdPos[1];
11808 RearTrainFrontPos = LeadElement;
11809 RearTrainRearPos = MidElement;
11810 if(FwdDerail1 || FwdDerail2)
11812 TrainController->
StopTTClockMessage(169, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11813 TemporaryDelay =
true;
11819 TrainController->
StopTTClockMessage(170, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11820 TemporaryDelay =
true;
11826 TrainController->
StopTTClockMessage(171, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11827 TemporaryDelay =
true;
11835 else if((NumFwdElements >= 1) && (NumRwdNamedElements >= 1) && (NumRwdElements >= 2))
11837 FrontTrainFrontPos = FwdPos[1];
11838 FrontTrainRearPos = LeadElement;
11839 RearTrainFrontPos = MidElement;
11840 RearTrainRearPos = RwdPos[1];
11843 TrainController->
StopTTClockMessage(172, HeadCode +
" unable to split at " + LocationName +
", points set wrongly ahead of train. Please change these points to allow the split.");
11844 TemporaryDelay =
true;
11850 TrainController->
StopTTClockMessage(173, HeadCode +
" unable to split at " + LocationName +
", points set wrongly behind train. Please change these points to allow the split.");
11851 TemporaryDelay =
true;
11857 TrainController->
StopTTClockMessage(174, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing ahead of this train. Please move the obstructing train to allow the split.");
11858 TemporaryDelay =
true;
11864 TrainController->
StopTTClockMessage(175, HeadCode +
" unable to split at " + LocationName +
" because another train is obstructing behind this train. Please move the obstructing train to allow the split.");
11865 TemporaryDelay =
true;
11885 if(SNRange.first != SNRange.second)
11887 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
11889 if(SNIterator->second < 0)
11911 "," + AnsiString(SpeedTag));
11922 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
11952 else if(SpeedTag == 69)
11978 else if(SpeedTag == 70)
12004 else if(SpeedTag == 71)
12041 AnsiString(LinkPos) +
"," + AnsiString(OwnTrainID));
12042 if((LinkPos < 0) || (TrackPos < 0))
12074 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
12086 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
12087 bool FoundFlag =
false;
12102 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
12103 bool FoundFlag =
false;
12128 VPosHi = 16 * VLocHi;
12129 VPosLo = 16 * VLocLo;
12148 AnsiString(EndTVPosition));
12159 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
12160 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
12161 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
12162 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
12164 if(Link0Squares <= Link1Squares)
12182 AnsiString(LinkPos));
12201 if((LinkPos == 1) && (TE.
Attribute == 0))
12206 else if(LinkPos == 1)
12212 else if((LinkPos == 3) && (TE.
Attribute == 1))
12217 else if(LinkPos == 3)
12224 else if(LinkPos == 0)
12229 else if(LinkPos == 1)
12234 else if(LinkPos == 2)
12239 else if(LinkPos == 3)
12244 throw Exception(
"Error, failure in GetExitPos");
12293 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
12297 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
12339 "," + AnsiString(DiagonalLinkNumber));
12393 AnsiString JustFileName =
"";
12398 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
12405 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
12424 typedef std::list<int> TNamePosList;
12425 TNamePosList NamePosList;
12426 typedef TNamePosList::iterator TNPLIt;
12428 typedef std::list<int> TOnePlatList;
12429 TOnePlatList OnePlatList;
12430 typedef TOnePlatList::iterator TOPLIt;
12433 NamePosList.clear();
12434 OnePlatList.clear();
12435 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
12437 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
12439 NamePosList.push_back(x);
12444 if(!NamePosList.empty())
12446 OnePlatList.push_back(NamePosList.back());
12447 NamePosList.pop_back();
12449 while(!OnePlatList.empty())
12451 TempInt = OnePlatList.front();
12454 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
12455 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
12457 OnePlatList.push_back(TempElement.
Conn[0]);
12458 NamePosList.erase(NPLIt);
12460 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
12461 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
12463 OnePlatList.push_back(TempElement.
Conn[1]);
12464 NamePosList.erase(NPLIt);
12467 OnePlatList.erase(OnePlatList.begin());
12468 if(OnePlatList.empty())
12471 if(!NamePosList.empty())
12473 OnePlatList.push_back(NamePosList.back());
12474 NamePosList.pop_back();
12490 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not signal in RepairFailedSignals");
12494 throw Exception(
"Signals not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedSignals");
12522 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not points in RepairFailedPoints");
12526 throw Exception(
"Points not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedPoints");
12552 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not simple in RepairFailedPoints");
12556 throw Exception(
"No TSR at " + AnsiString(FPVIt->TVPos) +
" in RepairTSR");
12578 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
12599 if(TempElement.
Link[0] == LinkIn)
12618 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
12633 throw Exception(
"Return value negative in call to LastElementNumber");
12645 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
12659 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
12671 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
12672 " in GetModifiablePrefDirElementAt");
12682 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
12684 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
12694 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
12696 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
12713 int TrackVectorPosition;
12764 FinishElement =
false;
12765 int TrackVectorPosition;
12787 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
12797 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
12820 for(
int x = 0; x < 4; x++)
12843 FinishElement =
true;
12851 for(
int x = 0; x < 4; x++)
12863 FinishElement =
true;
12871 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12878 .ELinkPos] ==
Lead))
12894 FinishElement =
true;
12913 FinishElement =
true;
12932 FinishElement =
true;
12947 FinishElement =
true;
12956 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12972 FinishElement =
true;
12978 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
13001 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
13002 int VectorCount = 0;
13006 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
13008 for(
int x = 0; x < VectorCount; x++)
13015 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
13019 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
13020 SearchElement.
ELinkPos = NextELinkPos;
13041 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
13043 SearchElement.
XLinkPos = NextXLinkPos;
13069 for(
int x = 0; x < VectorCount; x++)
13081 for(
int x = 0; x < VectorCount; x++)
13095 for(
int x = 0; x < VectorCount; x++)
13109 for(
int x = 0; x < VectorCount; x++)
13119 for(
int x = 0; x < VectorCount; x++)
13130 SearchElement.
XLink = SearchElement.
Link[1];
13149 SearchElement.
XLink = SearchElement.
Link[3];
13162 for(
int x = 0; x < VectorCount; x++)
13177 XLinkPos = NextXLinkPos;
13178 CurrentTrackElement = SearchElement;
13197 throw Exception(
"Error, SearchVector empty");
13204 for(
int x = 0; x < 4; x++)
13257 throw Exception(
"Error in EntryExitNumber 1");
13276 if(PrefDirElement.
XLink == -1)
13288 if(PrefDirElement.
XLink != -1)
13292 throw Exception(
"Error in EntryExitNumber 2");
13330 LeadingPoints =
false;
13358 LeadingPoints =
true;
13374 AnsiString ErrorString;
13375 bool Error =
false;
13382 ErrorString =
"HLoc";
13388 ErrorString =
"VLoc";
13394 ErrorString =
"ELink";
13400 ErrorString =
"ELinkPos";
13406 ErrorString =
"XLink";
13412 ErrorString =
"XLinkPos";
13418 ErrorString =
"Tag";
13424 ErrorString =
"TrackVectorPosition";
13430 ErrorString =
"EXNumber";
13437 ErrorString =
"CheckCount";
13444 ErrorString =
"EntryGraphicPtr";
13450 ErrorString =
"EntryDirectionGraphicPtr";
13459 ErrorString =
"Last XLink not connected to this element";
13466 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
13490 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
13547 AnsiString((
short)BuildingPrefDir));
13550 if(PrefDirSize() == 0)
13555 for(
unsigned int x = 0; x < PrefDirSize(); x++)
13567 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
13579 if(x == (PrefDirSize() - 1))
13588 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
13590 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
13591 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
13592 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
13594 if(PrefDirSize() > 1)
13596 unsigned int LatestPos = PrefDirSize() - 1;
13597 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
13598 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
13599 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
13620 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13623 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
13627 H = MMIT->first.first;
13628 V = MMIT->first.second;
13631 if(PrefDirPos0 > -1)
13635 if(PrefDirPos1 > -1)
13639 if(PrefDirPos2 > -1)
13643 if(PrefDirPos3 > -1)
13647 if(PrefDirPos3 > -1)
13663 else if(PrefDirPos2 > -1)
13705 else if(PrefDirPos1 > -1)
13728 else if(PrefDirPos0 > -1)
13747 int NumberOfPrefDirElements = 0;
13750 for(
int x = 0; x < NumberOfPrefDirElements; x++)
13752 VecFile >> TempInt;
13755 VecFile >> TempInt;
13756 LoadPrefDirElement.
ELink = TempInt;
13757 VecFile >> TempInt;
13758 LoadPrefDirElement.
ELinkPos = TempInt;
13759 VecFile >> TempInt;
13760 LoadPrefDirElement.
XLink = TempInt;
13761 VecFile >> TempInt;
13762 LoadPrefDirElement.
XLinkPos = TempInt;
13763 VecFile >> TempInt;
13764 LoadPrefDirElement.
EXNumber = TempInt;
13765 VecFile >> TempInt;
13770 if(!(LoadPrefDirElement.
IsARoute))
13796 int NumberOfPrefDirElements = 0;
13799 for(
int x = 0; x < NumberOfPrefDirElements; x++)
13801 VecFile >> TempInt;
13802 VecFile >> TempInt;
13805 VecFile >> TempInt;
13806 LoadPrefDirElement.
ELink = TempInt;
13807 VecFile >> TempInt;
13808 LoadPrefDirElement.
ELinkPos = TempInt;
13809 VecFile >> TempInt;
13810 LoadPrefDirElement.
XLink = TempInt;
13811 VecFile >> TempInt;
13812 LoadPrefDirElement.
XLinkPos = TempInt;
13813 VecFile >> TempInt;
13814 LoadPrefDirElement.
EXNumber = TempInt;
13815 VecFile >> TempInt;
13820 if(!(LoadPrefDirElement.
IsARoute))
13848 int NumberOfPrefDirElements = 0;
13851 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
13856 for(
int x = 0; x < NumberOfPrefDirElements; x++)
13863 VecFile >> TempInt;
13864 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
13869 VecFile >> TempInt;
13870 if((TempInt < -1) || (TempInt > 9))
13875 VecFile >> TempInt;
13876 if((TempInt < -1) || (TempInt > 3))
13881 VecFile >> TempInt;
13882 if((TempInt < -1) || (TempInt > 9))
13887 VecFile >> TempInt;
13888 if((TempInt < -1) || (TempInt > 3))
13893 VecFile >> TempInt;
13894 if((TempInt < -1) || (TempInt > 27))
13899 VecFile >> TempInt;
13907 VecFile >> TempInt;
13908 if((TempInt != 0) && (TempInt != 1))
13913 VecFile >> TempInt;
13914 if((TempInt != 0) && (TempInt != 1))
13919 VecFile >> TempInt;
13920 if((TempInt != 0) && (TempInt != 1))
13943 for(
int y = 0; y < NumberOfPrefDirElements; y++)
13945 VecFile << y <<
'\n';
13946 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
13956 if(y == (NumberOfPrefDirElements - 1))
13958 VecFile <<
"************" <<
'\0' <<
'\n';
13962 VecFile <<
"******" <<
'\0' <<
'\n';
13976 for(
int y = 0; y < NumberOfSearchElements; y++)
13978 VecFile << y <<
'\n';
13979 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
13989 if(y == (NumberOfSearchElements - 1))
13991 VecFile <<
"************" <<
'\0' <<
'\n';
13995 VecFile <<
"******" <<
'\0' <<
'\n';
14108 bool AlreadyPresent, FoundFlag;
14109 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14111 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
14115 AlreadyPresent =
false;
14120 AlreadyPresent =
true;
14124 AlreadyPresent =
true;
14128 AlreadyPresent =
true;
14132 AlreadyPresent =
true;
14135 if(!AlreadyPresent)
14182 for(
unsigned int z = 0; z < 4; z++)
14190 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
14204 bool DiscrepancyFound =
false;
14215 DiscrepancyFound =
true;
14220 DiscrepancyFound =
true;
14225 DiscrepancyFound =
true;
14230 DiscrepancyFound =
true;
14235 DiscrepancyFound =
true;
14241 DiscrepancyFound =
true;
14244 if(DiscrepancyFound)
14246 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
14261 bool DiscrepancyFound =
false;
14272 DiscrepancyFound =
true;
14276 DiscrepancyFound =
true;
14281 DiscrepancyFound =
true;
14286 DiscrepancyFound =
true;
14291 DiscrepancyFound =
true;
14297 DiscrepancyFound =
true;
14301 return(!DiscrepancyFound);
14313 bool FoundFlag =
false;
14314 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
14322 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
14323 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
14325 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
14327 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
14328 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
14329 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
14334 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
14335 +
" Caller=" + (AnsiString)Caller);
14361 PrefDirMapKeyPair.first = HLoc;
14362 PrefDirMapKeyPair.second = VLoc;
14363 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
14366 if(ItPair.first == ItPair.second)
14374 PrefDirPos0 = ItPair.first->second;
14376 if(ItPair.first == ItPair.second)
14381 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
14383 PrefDirPos1 = ItPair.first->second;
14386 if(ItPair.first == ItPair.second)
14391 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
14393 PrefDirPos2 = ItPair.first->second;
14396 if(ItPair.first == ItPair.second)
14401 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
14403 PrefDirPos3 = ItPair.first->second;
14418 +
"," + AnsiString(LinkNumberPos));
14420 int PD0, PD1, PD2, PD3;
14421 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
14425 PD0, PD1, PD2, PD3);
14437 LinkedPrefDirVectorNumber = PD0;
14446 LinkedPrefDirVectorNumber = PD1;
14456 LinkedPrefDirVectorNumber = PD0;
14465 LinkedPrefDirVectorNumber = PD1;
14474 LinkedPrefDirVectorNumber = PD2;
14483 LinkedPrefDirVectorNumber = PD3;
14488 LinkedPrefDirVectorNumber = -1;
14494 LinkedPrefDirVectorNumber = -1;
14499 catch(
const Exception &e)
14501 LinkedPrefDirVectorNumber = -1;
14516 +
"," + AnsiString(LinkNumberPos));
14518 int PD0, PD1, PD2, PD3;
14519 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
14523 PD0, PD1, PD2, PD3);
14536 LinkedPrefDirVectorNumber = PD0;
14546 LinkedPrefDirVectorNumber = PD1;
14551 LinkedPrefDirVectorNumber = -1;
14559 LinkedPrefDirVectorNumber = PD0;
14568 LinkedPrefDirVectorNumber = PD1;
14577 LinkedPrefDirVectorNumber = PD2;
14586 LinkedPrefDirVectorNumber = PD3;
14591 LinkedPrefDirVectorNumber = -1;
14597 LinkedPrefDirVectorNumber = -1;
14602 catch(
const Exception &e)
14604 LinkedPrefDirVectorNumber = -1;
14616 int PD0, PD1, PD2, PD3;
14668 THVPair PrefDir4MultiMapKeyPair;
14671 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
14672 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
14673 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
14696 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
14715 AnsiString(ErasedElementNumber));
14720 if(MapPtr->second > ErasedElementNumber)
14742 throw Exception(
"PrefDirVectorPosition out of range");
14745 THVPair PrefDir4MultiMapKeyPair;
14747 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
14748 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
14749 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
14752 if(ItPair.first == ItPair.second)
14755 return(ItPair.first);
14759 if(ItPair.first->second == PrefDirVectorPosition)
14763 return(ItPair.first);
14766 if(ItPair.first == ItPair.second)
14769 return(ItPair.first);
14771 if(ItPair.first->second == PrefDirVectorPosition)
14775 return(ItPair.first);
14778 if(ItPair.first == ItPair.second)
14781 return(ItPair.first);
14783 if(ItPair.first->second == PrefDirVectorPosition)
14787 return(ItPair.first);
14790 if(ItPair.first == ItPair.second)
14793 return(ItPair.first);
14795 if(ItPair.first->second == PrefDirVectorPosition)
14799 return(ItPair.first);
14803 return(ItPair.first);
14816 THVPair PrefDir4MultiMapKeyPair;
14818 PrefDir4MultiMapKeyPair.first = HLoc;
14819 PrefDir4MultiMapKeyPair.second = VLoc;
14820 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
14823 if(ItPair.first == ItPair.second)
14831 return(ItPair.first->second);
14840 bool ErasedFlag =
false;
14842 if(ErasedTrackVectorPosition > -1)
14851 ErasedFlag =
false;
14853 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
14858 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
14863 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
14868 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
14873 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
14881 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
14885 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
14889 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
14893 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
14897 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
14912 OverallDistance = 0;
14913 OverallSpeedLimit = 0;
14914 LeadingPointsAtLastElement =
false;
14922 LeadingPointsAtLastElement =
true;
14931 OverallDistance += PrefDirElement.
Length23;
14932 if(OverallSpeedLimit != -1)
14942 OverallSpeedLimit = -1;
14949 OverallDistance += PrefDirElement.
Length01;
14950 if(OverallSpeedLimit != -1)
14960 OverallSpeedLimit = -1;
14979 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14982 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14986 HLoc = MMIT->first.first;
14987 VLoc = MMIT->first.second;
14992 if(PrefDirPos0 > -1)
14996 if(PrefDirPos1 > -1)
15000 if(PrefDirPos2 > -1)
15004 if(PrefDirPos3 > -1)
15008 if(PrefDirPos3 > -1)
15011 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
15013 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
15015 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
15017 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
15024 else if(PrefDirPos2 > -1)
15029 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
15031 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
15033 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
15042 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
15044 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
15046 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
15055 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
15057 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
15059 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
15066 else if(PrefDirPos1 > -1)
15071 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
15073 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
15081 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
15083 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
15089 else if(PrefDirPos0 > -1)
15091 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
15108 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
15111 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
15133 if(PrefDirPos0 > -1)
15137 if(PrefDirPos1 > -1)
15141 if(PrefDirPos2 > -1)
15145 if(PrefDirPos3 > -1)
15149 if(PrefDirPos3 > -1)
15154 else if(PrefDirPos2 > -1)
15156 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
15167 else if(PrefDirPos1 > -1)
15169 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
15180 else if(PrefDirPos0 > -1)
15182 if(PrefDirElement0.
XLinkPos == EntryPos)
15222 ElementIn.
VLoc +
"," + XLink);
15224 bool TrackFoundFlag;
15232 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
15245 ((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3)))
15256 && ((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7)))
15271 && ((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1)))
15282 && ((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9)))
15297 && ((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9)))
15308 && ((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1)))
15323 && ((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7)))
15334 && ((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3)))
15357 bool FoundFlag, ContFlag, FoundElements =
false;
15358 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
15363 LastIteratorValue++;
15390 if(PDVIt->XLinkPos == 0)
15395 StartElement = *PDVIt;
15404 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
15406 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
15407 if(PrefDirPos0 == -1)
15411 bool NextElementFoundFlag =
false;
15415 NextElementFoundFlag =
true;
15417 if(PrefDirPos1 > -1)
15422 NextElementFoundFlag =
true;
15425 if(PrefDirPos2 > -1)
15430 NextElementFoundFlag =
true;
15433 if(PrefDirPos3 > -1)
15438 NextElementFoundFlag =
true;
15441 if(!NextElementFoundFlag)
15471 EndElement = NextElement;
15475 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
15477 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
15478 if(PrefDirPos0 == -1)
15488 if(PrefDirPos1 > -1)
15496 if(PrefDirPos2 > -1)
15504 if(PrefDirPos3 > -1)
15535 FoundElements =
true;
15569 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
15571 int TrackVectorPosition;
15607 int LockedVectorNumber;
15630 bool InPrefDirFlag =
false;
15633 int PrefDirPos0 = -1;
15634 int PrefDirPos1 = -1;
15635 int PrefDirPos2 = -1;
15636 int PrefDirPos3 = -1;
15640 int PrefDirVecPos[4] =
15642 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15645 for(
int x = 0; x < 4; x++)
15647 int b = PrefDirVecPos[x];
15657 InPrefDirFlag =
true;
15670 TrainController->
StopTTClockMessage(12,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
15678 if(DummyPair.first > -1)
15680 throw Exception(
"Selection in two routes - should never happen!");
15682 if(RoutePair.first > -1)
15758 IDInt &ReqPosRouteID,
bool &PointsChanged)
15792 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignals) +
"," + AnsiString((
short)AutoSigsFlag));
15794 int NewFailedPointsTVPos = -1;
15843 bool InPrefDirFlag =
false;
15846 int PrefDirPos0 = -1;
15847 int PrefDirPos1 = -1;
15848 int PrefDirPos2 = -1;
15849 int PrefDirPos3 = -1;
15852 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
15853 int PrefDirVecPos[4] =
15855 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15858 for(
int x = 0; x < 4; x++)
15860 int b = PrefDirVecPos[x];
15863 InPrefDirFlag =
true;
15876 TrainController->
StopTTClockMessage(23,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
15885 if(RoutePair.first > -1)
15887 if(RoutePair.second != 0)
15904 EndElement1 = RouteElement;
15905 EndElement2 = BlankElement;
16000 AutoSigsFlag,
false))
16005 if(NewFailedPointsTVPos > -1)
16009 " failed during route setting.");
16013 PointsChanged =
true;
16036 AutoSigsFlag,
false))
16041 if(NewFailedPointsTVPos > -1)
16045 " failed during route setting.");
16049 PointsChanged =
true;
16067 AutoSigsFlag,
false))
16072 if(NewFailedPointsTVPos > -1)
16076 " failed during route setting.");
16080 PointsChanged =
true;
16104 AutoSigsFlag,
false))
16109 if(NewFailedPointsTVPos > -1)
16113 " failed during route setting.");
16117 PointsChanged =
true;
16126 AutoSigsFlag,
false))
16131 if(NewFailedPointsTVPos > -1)
16135 " failed during route setting.");
16139 PointsChanged =
true;
16150 AutoSigsFlag,
false))
16155 if(NewFailedPointsTVPos > -1)
16159 " failed during route setting.");
16163 PointsChanged =
true;
16169 AutoSigsFlag,
false))
16174 if(NewFailedPointsTVPos > -1)
16178 " failed during route setting.");
16182 PointsChanged =
true;
16193 AutoSigsFlag,
false))
16198 if(NewFailedPointsTVPos > -1)
16202 " failed during route setting.");
16206 PointsChanged =
true;
16260 TOnePrefDir *EveryPrefDir,
bool ConsecSignals,
int EndPosition,
bool AutoSigsFlag,
bool RecursiveCall)
16312 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
16313 AnsiString((
short)AutoSigsFlag) +
"," + AnsiString((
short)RecursiveCall));
16314 int VectorCount = 0;
16323 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
16327 for(
int x = 0; x < VectorCount; x++)
16335 bool FirstPass =
true;
16345 for(
int x = 0; x < VectorCount; x++)
16354 for(
int x = 0; x < VectorCount; x++)
16366 for(
int x = 0; x < VectorCount; x++)
16374 int NextPosition = PrefDirElement.
Conn[XLinkPos];
16378 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
16379 SearchElement.
ELinkPos = NextELinkPos;
16380 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
16401 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
16403 SearchElement.
XLinkPos = NextXLinkPos;
16421 for(
int x = 0; x < VectorCount; x++)
16437 for(
int x = 0; x < VectorCount; x++)
16451 if(RoutePair.first > -1)
16460 for(
int x = 0; x < VectorCount; x++)
16469 if(SecondPair.first > -1)
16478 for(
int x = 0; x < VectorCount; x++)
16492 for(
int x = 0; x < VectorCount; x++)
16503 for(
int x = 0; x < VectorCount; x++)
16512 for(
int x = 0; x < VectorCount; x++)
16521 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16525 for(
int x = 0; x < VectorCount; x++)
16535 bool InPrefDirFlag =
false;
16536 PrefDirElement1 = BlankElement;
16537 PrefDirElement2 = BlankElement;
16540 int PrefDirPos0 = -1;
16541 int PrefDirPos1 = -1;
16542 int PrefDirPos2 = -1;
16543 int PrefDirPos3 = -1;
16546 int PrefDirVecPos[4] =
16548 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
16550 for(
int x = 0; x < 4; x++)
16552 int b = PrefDirVecPos[x];
16555 InPrefDirFlag =
true;
16568 for(
int x = 0; x < VectorCount; x++)
16580 for(
int x = 0; x < VectorCount; x++)
16596 for(
int x = 0; x < VectorCount; x++)
16607 for(
int x = 0; x < VectorCount; x++)
16627 for(
int x = 0; x < VectorCount; x++)
16640 for(
int x = 0; x < VectorCount; x++)
16654 for(
int x = 0; x < VectorCount; x++)
16664 for(
int x = 0; x < VectorCount; x++)
16695 for(
int x = 0; x < VectorCount; x++)
16704 for(
int x = 0; x < VectorCount; x++)
16716 int SearchPos1 = SearchElement.
Attribute + 1;
16718 if(SearchPos1 == 2)
16722 if(SearchPos1 == 1)
16730 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
16731 SearchElement.
XLinkPos = SearchPos1;
16732 InPrefDirFlag =
false;
16733 if(SearchElement.
XLink == PrefDirElement1.
XLink)
16735 SearchElement = PrefDirElement1;
16736 InPrefDirFlag =
true;
16738 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
16740 SearchElement = PrefDirElement2;
16741 InPrefDirFlag =
true;
16747 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16751 for(
int x = 0; x < VectorCount; x++)
16769 AutoSigsFlag,
true))
16778 for(
int x = 0; x < VectorCount; x++)
16787 for(
int x = 0; x < VectorCount; x++)
16807 for(
int x = 0; x < VectorCount; x++)
16817 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
16818 SearchElement.
XLinkPos = SearchPos2;
16819 if(SearchElement.
XLink == PrefDirElement1.
XLink)
16821 SearchElement = PrefDirElement1;
16823 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
16825 SearchElement = PrefDirElement2;
16829 for(
int x = 0; x < VectorCount; x++)
16837 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16841 for(
int x = 0; x < VectorCount; x++)
16860 AutoSigsFlag,
true))
16869 for(
int x = 0; x < VectorCount; x++)
16878 for(
int x = 0; x < VectorCount; x++)
16890 for(
int x = 0; x < VectorCount; x++)
16900 SearchElement = PrefDirElement1;
16909 XLinkPos = SearchElement.
XLinkPos;
16910 PrefDirElement = SearchElement;
16967 unsigned int TruncatePrefDirPosition = 0;
17040 throw Exception(
"Error - failed to validate extended route for preferred route");
17095 throw Exception(
"Error - failed to validate single route for preferred route");
17140 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
17142 int TrackVectorPosition;
17179 int LockedVectorNumber;
17213 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
17214 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
17217 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
17223 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
17224 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
17227 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
17241 if(RoutePair.first > -1)
17376 int NewFailedPointsTVPos = -1;
17441 EndElement1.
ELink = EndElement1.
Link[0];
17442 EndElement1.
XLink = EndElement1.
Link[1];
17445 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
17450 EndElement2.
ELink = EndElement2.
Link[1];
17451 EndElement2.
XLink = EndElement2.
Link[0];
17454 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
17498 if(RoutePair.first > -1)
17500 if(RoutePair.second != 0)
17523 EndElement2 = BlankElement;
17608 if(NewFailedPointsTVPos > -1)
17612 " failed during route setting.");
17616 PointsChanged =
true;
17642 if(NewFailedPointsTVPos > -1)
17646 " failed during route setting.");
17650 PointsChanged =
true;
17672 if(NewFailedPointsTVPos > -1)
17676 " failed during route setting.");
17680 PointsChanged =
true;
17706 if(NewFailedPointsTVPos > -1)
17710 " failed during route setting.");
17714 PointsChanged =
true;
17728 if(NewFailedPointsTVPos > -1)
17732 " failed during route setting.");
17736 PointsChanged =
true;
17776 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
17777 int VectorCount = 0;
17780 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
17781 (CurrentTrackElement.
Link[XLinkPos] == 9))
17785 for(
int x = 0; x < VectorCount; x++)
17797 for(
int x = 0; x < VectorCount; x++)
17804 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
17806 for(
int x = 0; x < VectorCount; x++)
17813 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
17817 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
17818 SearchElement.
ELinkPos = NextELinkPos;
17839 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
17841 SearchElement.
XLinkPos = NextXLinkPos;
17859 for(
int x = 0; x < VectorCount; x++)
17875 for(
int x = 0; x < VectorCount; x++)
17889 if(RoutePair.first > -1)
17898 for(
int x = 0; x < VectorCount; x++)
17907 if(SecondPair.first > -1)
17916 for(
int x = 0; x < VectorCount; x++)
17930 for(
int x = 0; x < VectorCount; x++)
17941 for(
int x = 0; x < VectorCount; x++)
17950 for(
int x = 0; x < VectorCount; x++)
17959 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17963 for(
int x = 0; x < VectorCount; x++)
17976 for(
int x = 0; x < VectorCount; x++)
18004 for(
int x = 0; x < VectorCount; x++)
18017 for(
int x = 0; x < VectorCount; x++)
18027 for(
int x = 0; x < VectorCount; x++)
18052 for(
int x = 0; x < VectorCount; x++)
18061 for(
int x = 0; x < VectorCount; x++)
18074 int SearchPos1 = SearchElement.
Attribute + 1;
18076 if(SearchPos1 == 2)
18080 if(SearchPos1 == 1)
18089 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
18090 SearchElement.
XLinkPos = SearchPos1;
18092 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
18096 for(
int x = 0; x < VectorCount; x++)
18114 for(
int x = 0; x < VectorCount; x++)
18130 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
18131 SearchElement.
XLinkPos = SearchPos2;
18133 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
18137 for(
int x = 0; x < VectorCount; x++)
18153 for(
int x = 0; x < VectorCount; x++)
18165 for(
int x = 0; x < VectorCount; x++)
18180 CurrentTrackElement = SearchElement;
18181 XLinkPos = SearchElement.
XLinkPos;
18203 throw Exception(
"Error, SearchVector empty");
18215 for(
int x = 0; x < 4; x++)
18257 throw Exception(
"Error in EntryExitNumber 3");
18312 unsigned int TruncatePrefDirPosition = 0;
18372 throw Exception(
"Failed to validate extended route for nonpreferred route");
18417 throw Exception(
"Failed to validate single route for nonpreferred route");
18437 if(!PrefDirVector.empty())
18441 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
18446 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
18463 if(!PrefDirVector.empty())
18468 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
18485 NewFailedPointsTVPos = -1;
18486 bool PointsChanged =
false;
18494 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
18504 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
18505 IFE.
TVPos = NewFailedPointsTVPos;
18524 PointsChanged =
true;
18527 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
18537 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
18538 IFE.
TVPos = NewFailedPointsTVPos;
18557 PointsChanged =
true;
18563 return(PointsChanged);
18587 NextForwardLinkedRouteNumber = -1;
18588 for(
unsigned int x = StartPos; x < PrefDirSize(); x++)
18590 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
18591 if(PrefDirVector.at(x).TrackType ==
Bridge)
18593 if(PrefDirVector.at(x).XLinkPos < 2)
18595 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit01;
18599 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit23;
18607 if(PrefDirVector.at(x).TrackType ==
Buffers)
18619 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
18628 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
18630 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute;
18642 if(x == PrefDirSize() - 1)
18645 NextForwardLinkedRouteNumber = -1;
18693 AnsiString(PrefDirVectorStartPosition));
18699 if(!PrefDirVector.empty())
18701 if(!SkipForwardLook)
18703 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
18706 if(PrefDirPtr->TrackType ==
Bridge)
18708 if(PrefDirPtr->XLinkPos < 2)
18719 SkipForwardLook =
true;
18727 SkipForwardLook =
true;
18730 int NextForwardLinkedRouteNumber = -1;
18731 if((
unsigned int)PrefDirVectorStartPosition == PrefDirSize() - 1)
18733 TPrefDirElement PDE = GetFixedPrefDirElementAt(267, PrefDirVectorStartPosition);
18738 SkipForwardLook =
true;
18739 if(PrefDirVector.back().TrackType ==
Buffers)
18745 bool SetAttributeTo3 =
true;
18756 SetAttributeTo3 =
false;
18757 Attribute = AutoSigVectorIT->AccessNumber;
18763 if(SetAttributeTo3)
18774 SkipForwardLook =
true;
18775 if(PrefDirVector.back().TrackType ==
Buffers)
18788 if(!SkipForwardLook)
18793 if((
unsigned int)PrefDirVectorStartPosition < (PrefDirSize() - 1))
18795 StartPos = PrefDirVectorStartPosition + 1;
18803 if(!FindForwardTargetSignalAttribute(2, NextForwardLinkedRouteNumber, Attribute, StartPos))
18822 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
18825 if(PrefDirPtr->TrackType ==
Bridge)
18827 if(PrefDirPtr->XLinkPos < 2)
18843 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
18852 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
18854 if((!
AllRoutes->
RouteTruncateFlag) || (PrefDirPtr != (PrefDirVector.begin() + PrefDirVectorStartPosition)) || PrefDirPtr->AutoSignals ||
18855 PrefDirPtr->PrefDirRoute)
18859 int LockedVecNum = 0;
18861 bool KeepAttributeAt0ForLockedRoute =
false;
18866 KeepAttributeAt0ForLockedRoute =
true;
18871 bool NotGroundSignal =
false;
18874 NotGroundSignal =
true;
18899 if((Attribute < 3) && !KeepAttributeAt0ForLockedRoute && (NotGroundSignal || (Attribute == 0)))
18930 "," + AnsiString((
short)PrefDirRoute));
18931 bool ElementInRoute =
false;
18933 int LastElementToBeTruncated = -1;
18934 bool MovingTrainOccupyingRoute =
false;
18935 unsigned int TruncatePDElementPos;
18936 enum {NoTruncate, BackTruncate, FrontTruncate, NextSignalTruncate, FullTruncate} TruncateType;
18937 TruncateType = NoTruncate;
18944 TruncatePDElementPos = b;
18945 ElementInRoute =
true;
18949 if(!ElementInRoute)
18975 if(TruncatePDElementPos == 0)
18977 TruncateType = FullTruncate;
18988 TruncateType = FrontTruncate;
18996 TruncatePDElementPos++;
18999 for(b =
int(TruncatePDElementPos); b < int(
PrefDirSize()); b++)
19004 TruncateType = NextSignalTruncate;
19011 TruncateType = BackTruncate;
19017 TruncateType = BackTruncate;
19025 TruncateType = BackTruncate;
19031 if(TruncateType == BackTruncate)
19051 MovingTrainOccupyingRoute =
true;
19062 if(b ==
int(TruncatePDElementPos))
19068 else if(TruncateType == NextSignalTruncate)
19072 LastElementToBeTruncated = -1;
19073 for(
unsigned int b = TruncatePDElementPos; b <
PrefDirSize(); b++)
19078 LastElementToBeTruncated = int(b) - 1;
19082 for(
int b = LastElementToBeTruncated; b >= 0; b--)
19100 MovingTrainOccupyingRoute =
true;
19111 if(b ==
int(TruncatePDElementPos))
19117 ReinstatementRoute = *
this;
19126 else if(TruncateType == FrontTruncate)
19146 MovingTrainOccupyingRoute =
true;
19157 if(b == TruncatePDElementPos)
19183 MovingTrainOccupyingRoute =
true;
19204 if(((TruncatePDElementPos == 1) && (TruncateType == BackTruncate)) || ((TruncatePDElementPos == (
PrefDirSize() - 2)) && (TruncateType == FrontTruncate)))
19213 if((TruncatePDElementPos > 0) && (TruncateType == BackTruncate))
19220 TrainController->
StopTTClockMessage(145,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
19221 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
19222 "that lies within the route;\n\nto truncate to the next signal that isn't the end of the route select a signal to truncate from;\n\n"
19223 "or to remove the whole route select the first track element in the route");
19243 else if((TruncatePDElementPos < (
PrefDirSize() - 1)) && (TruncateType == FrontTruncate))
19250 TrainController->
StopTTClockMessage(146,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
19251 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
19252 "that lies within the route;\n\nto truncate to the next signal that isn't the end of the route select a signal to truncate from;\n\n"
19253 "or to remove the whole route select the first track element in the route");
19279 else if(TruncatePDElementPos == 0)
19286 TrainController->
StopTTClockMessage(148,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
19287 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
19288 "that lies within the route;\n\nto truncate to the next signal that isn't the end of the route select a signal to truncate from;\n\n"
19289 "or to remove the whole route select the first track element in the route");
19309 int ThisRouteNumber;
19319 if(LRVIT->RouteNumber == ThisRouteNumber)
19330 unsigned int LookBackwardsFromHere = 0;
19331 if((TruncateType == BackTruncate) || (TruncateType == NextSignalTruncate))
19333 LookBackwardsFromHere = TruncatePDElementPos;
19343 if(TruncateType == NextSignalTruncate)
19346 "immediately after the signal, this will lock the remainder of the route ");
19356 int button = Application->MessageBox(L
"Moving train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
19357 L
"Warning!", MB_YESNO | MB_ICONWARNING);
19370 bool ExistingLockedRouteModified =
false;
19372 if(TruncateType == BackTruncate)
19378 else if(TruncateType == FrontTruncate)
19399 if(LRVIT->RouteNumber == ThisRouteNumber)
19403 ExistingLockedRouteModified =
true;
19407 if(!ExistingLockedRouteModified)
19411 if(TruncateType == BackTruncate)
19414 RearPosition = TruncatePDElementPos;
19417 else if(TruncateType == FrontTruncate)
19421 FrontPosition = TruncatePDElementPos;
19430 for(
int c = FrontPosition; c >= RearPosition; c--)
19449 if((TruncateType == BackTruncate) || (TruncateType == NextSignalTruncate))
19451 RearPosition = TruncatePDElementPos;
19455 else if(TruncateType == FrontTruncate)
19458 FrontPosition = TruncatePDElementPos;
19475 for(
int c = FrontPosition; c >= RearPosition; c--)
19481 if(TruncateType == NextSignalTruncate)
19527 TPrefDirElement NewGreenFirstPDElement, NewRedFirstPDElement, NewGreenLastPDElement, NewRedLastPDElement;
19540 if(RouteColour == 1)
19542 NewRedFirstPDElement = LastPDElement;
19546 NewRedFirstPDElement.
IsARoute =
true;
19552 if(R2MMIt->second.first ==
int(x))
19554 R2MMIt->second.second++;
19561 else if(RouteColour == 2)
19563 NewGreenFirstPDElement = LastPDElement;
19567 NewGreenFirstPDElement.
IsARoute =
true;
19573 if(R2MMIt->second.first ==
int(x))
19575 R2MMIt->second.second++;
19598 if(RouteColour == 1)
19600 NewRedLastPDElement = FirstPDElement;
19609 else if(RouteColour == 2)
19611 NewGreenLastPDElement = FirstPDElement;
19680 ARVIt->SetRouteSignals(14);
19699 AnsiString((
short)PrefDirRoute));
19724 AnsiString((
short)PrefDirRoute));
19734 RouteFlashElement.
HLoc = H;
19735 RouteFlashElement.
VLoc = V;
19751 int H = PrefDirPtr->HLoc;
19752 int V = PrefDirPtr->VLoc;
19819 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
19825 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
19828 OverlayPlotted =
false;
19851 bool FirstSignalFound =
false;
19858 if(PDVIt->TrackType ==
Points)
19860 if((PDVIt->ELinkPos == 1) || (PDVIt->XLinkPos == 1))
19871 else if((PDVIt->ELinkPos == 3) || (PDVIt->XLinkPos == 3))
19886 int XLinkPosition = PDVIt->XLinkPos;
19887 if(PDVIt->XLinkPos == -1)
19891 for(
int x = 0; x < 4; x++)
19893 if(PDVIt->Conn[x] == (PDVIt + 1)->TrackVectorPosition)
19906 if(XLinkPosition > -1)
19908 if(!FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
19910 FirstSignalFound =
true;
19913 else if(FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
19924 IFE.
TVPos = PDVIt->TrackVectorPosition;
19930 " failed when changing aspect.\nTrains can only pass under signaller control.");
19960 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
19962 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
19965 return(AllRoutesVector.at(At));
19973 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
19975 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
19978 return(AllRoutesVector.at(At));
19989 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19991 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
20001 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
20003 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
20021 AnsiString(VLoc) +
"," + AnsiString((
short)PrefDirRoute));
20022 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
20026 GetModifiableRouteAt(7, a).TruncateRoute(0, HLoc, VLoc, PrefDirRoute, ReturnFlag);
20055 AnsiString(LinkPos));
20056 if(TrackVectorPosition == -1)
20061 THVPair Route2MultiMapKeyPair;
20065 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
20068 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
20078 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
20080 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
20083 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
20084 Route2MultiMapIterator->second.second);
20085 EntryLinkPos = PrefDirElement1.
ELinkPos;
20086 ExitLinkPos = PrefDirElement1.
XLinkPos;
20087 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
20088 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
20100 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
20112 Graphics::TBitmap* &EntryDirectionGraphicPtr)
20122 AnsiString(LinkPos));
20125 if(TrackVectorPosition == -1)
20130 THVPair Route2MultiMapKeyPair;
20134 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
20137 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
20142 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
20144 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
20146 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
20147 Route2MultiMapIterator->second.second);
20148 EntryLinkPos = PrefDirElement1.
ELinkPos;
20149 ExitLinkPos = PrefDirElement1.
XLinkPos;
20150 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
20151 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
20155 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
20156 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
20163 return(AutoSigsRoute);
20168 return(NotAutoSigsRoute);
20174 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
20175 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
20182 return(AutoSigsRoute);
20187 return(NotAutoSigsRoute);
20191 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
20193 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
20194 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20196 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
20197 EntryLinkPos = PrefDirElement2.
ELinkPos;
20198 ExitLinkPos = PrefDirElement2.
XLinkPos;
20199 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
20200 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
20204 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
20211 return(AutoSigsRoute);
20216 return(NotAutoSigsRoute);
20222 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
20229 return(AutoSigsRoute);
20234 return(NotAutoSigsRoute);
20238 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
20239 EntryLinkPos = PrefDirElement3.
ELinkPos;
20240 ExitLinkPos = PrefDirElement3.
XLinkPos;
20241 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
20242 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
20246 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
20253 return(AutoSigsRoute);
20258 return(NotAutoSigsRoute);
20264 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
20271 return(AutoSigsRoute);
20276 return(NotAutoSigsRoute);
20292 AnsiString(LinkPos));
20293 if(TrackVectorPosition == -1)
20299 THVPair Route2MultiMapKeyPair;
20303 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
20306 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
20312 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
20314 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
20316 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
20317 Route2MultiMapIterator->second.second);
20318 EntryLinkPos = PrefDirElement1.
ELinkPos;
20319 ExitLinkPos = PrefDirElement1.
XLinkPos;
20320 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
20321 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
20324 RouteNumber = Route2MultiMapIterator->second.first;
20328 return(AutoSigsRoute);
20333 return(NotAutoSigsRoute);
20338 RouteNumber = Route2MultiMapIterator->second.first;
20342 return(AutoSigsRoute);
20347 return(NotAutoSigsRoute);
20351 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
20353 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
20354 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20356 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
20357 EntryLinkPos = PrefDirElement2.
ELinkPos;
20358 ExitLinkPos = PrefDirElement2.
XLinkPos;
20359 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
20360 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
20363 RouteNumber = ItPair.first->second.first;
20367 return(AutoSigsRoute);
20372 return(NotAutoSigsRoute);
20377 RouteNumber = ItPair.first->second.first;
20381 return(AutoSigsRoute);
20386 return(NotAutoSigsRoute);
20390 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
20391 EntryLinkPos = PrefDirElement3.
ELinkPos;
20392 ExitLinkPos = PrefDirElement3.
XLinkPos;
20393 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
20394 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
20397 RouteNumber = ItPair.second->second.first;
20401 return(AutoSigsRoute);
20406 return(NotAutoSigsRoute);
20411 RouteNumber = ItPair.second->second.first;
20415 return(AutoSigsRoute);
20420 return(NotAutoSigsRoute);
20442 EmptyRoute.
RouteID = NextRouteID;
20445 AllRoutesVector.push_back(EmptyRoute);
20446 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
20470 AllRoutesVector.push_back(EmptyRoute);
20471 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
20494 THVPair Route2MultiMapKeyPair;
20503 LockedRouteRearTrackVectorPosition = 0;
20504 LockedRouteLastTrackVectorPosition = 0;
20505 LockedRouteLastXLinkPos = 0;
20506 LockedRouteLockStartTime = TDateTime(0);
20507 if(!LockedRouteVector.empty())
20511 if(LRVIT->RouteNumber == RouteNumber)
20513 LockedRouteRearTrackVectorPosition = LRVIT->RearTrackVectorPosition;
20514 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
20515 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
20516 LockedRouteLockStartTime = LRVIT->LockStartTime;
20517 LockedRouteFoundDuringRouteBuilding =
true;
20518 LockedRouteVector.erase(LRVIT);
20543 AnsiString(VLoc) +
"," + AnsiString(ELink));
20546 ReturnPair.first = -1;
20547 ReturnPair.second = 0;
20548 THVPair Route2MultiMapKeyPair;
20550 Route2MultiMapKeyPair.first = HLoc;
20551 Route2MultiMapKeyPair.second = VLoc;
20554 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
20555 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
20557 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20558 Route2MultiMapIterator = ItPair.first;
20560 if(ItPair.first == ItPair.second)
20562 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
20564 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
20566 ReturnPair.first = ItPair.first->second.first;
20567 ReturnPair.second = ItPair.first->second.second;
20568 Route2MultiMapIterator = ItPair.first;
20570 return(ReturnPair);
20573 if(ItPair.first == ItPair.second)
20575 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
20577 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
20579 ReturnPair.first = ItPair.first->second.first;
20580 ReturnPair.second = ItPair.first->second.second;
20581 Route2MultiMapIterator = ItPair.first;
20583 return(ReturnPair);
20586 return(ReturnPair);
20601 AnsiString(VLoc) +
"," + AnsiString(ELink));
20602 THVPair Route2MultiMapKeyPair;
20604 Route2MultiMapKeyPair.first = HLoc;
20605 Route2MultiMapKeyPair.second = VLoc;
20606 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
20608 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20610 if(ItPair.first == ItPair.second)
20616 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
20618 RouteNumber = ItPair.first->second.first;
20624 if(ItPair.first == ItPair.second)
20630 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
20632 RouteNumber = ItPair.first->second.first;
20653 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
20654 THVPair Route2MultiMapKeyPair;
20656 Route2MultiMapKeyPair.first = HLoc;
20657 Route2MultiMapKeyPair.second = VLoc;
20660 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
20663 RouteElementPair.first = RouteNumber;
20664 RouteElementPair.second = RouteElementNumber;
20665 Route2MultiMapEntry.second = RouteElementPair;
20667 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
20670 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
20671 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
20674 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
20675 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
20677 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
20679 Route2MultiMap.insert(Route2MultiMapEntry);
20684 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
20689 Route2MultiMap.insert(Route2MultiMapEntry);
20707 TempPair.first = -1;
20708 TempPair.second = 0;
20709 SecondPair = TempPair;
20711 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
20712 THVPair Route2MultiMapKeyPair;
20714 Route2MultiMapKeyPair.first = HLoc;
20715 Route2MultiMapKeyPair.second = VLoc;
20716 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
20721 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
20723 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
20725 return(Route2MultiMapIterator->second);
20727 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
20729 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
20730 TempPair = ItRange.first->second;
20731 SecondPair = (--ItRange.second)->second;
20754 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
20755 if(RouteElementPair.first == -1)
20758 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
20759 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
20761 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
20764 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
20765 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
20766 (AnsiString)Caller);
20768 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
20771 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
20772 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
20773 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
20774 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
20778 unsigned int SizeVal = 0;
20781 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
20783 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
20785 if(SizeVal != Route2MultiMap.size())
20787 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
20788 (AnsiString)Caller);
20804 if(!Route2MultiMap.empty())
20806 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
20808 if(Route2MultiMapIterator->second.first > RouteNumber)
20810 Route2MultiMapIterator->second.first--;
20827 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
20828 if(!Route2MultiMap.empty())
20830 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
20832 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
20834 Route2MultiMapIterator->second.second--;
20853 AnsiString(ELink));
20857 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
20858 if(RequiredRoutePair.first == -1)
20860 throw Exception(
"Failed to find route element in RemoveRouteElement");
20862 Route2MultiMap.erase(Route2MultiMapIterator);
20863 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
20866 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
20887 GetModifiableRouteAt(8, RequiredRoutePair.first).PrefDirVector.erase(GetModifiableRouteAt(33, RequiredRoutePair.first).PrefDirVector.begin() + RequiredRoutePair.second);
20898 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
20906 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
20908 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
20909 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
20910 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
20922 if(!LockedRouteVector.empty())
20926 if(LRVIT->RouteNumber > RequiredRoutePair.first)
20928 LRVIT->RouteNumber--;
20938 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
20940 AutoSigVectorIT->RouteNumber--;
20945 CheckMapAndRoutes(7);
20959 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
20960 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
20961 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
20978 "," + AnsiString(XLinkPos));
20982 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
20983 if(RouteElementPair.first == -1)
20985 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
20987 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
20989 RequiredPair = RouteElementPair;
20990 if(RouteElement.
XLinkPos != XLinkPos)
20992 if(SecondPair.first != -1)
20994 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
20995 RequiredPair = SecondPair;
20996 if(RouteElement.
XLinkPos != XLinkPos)
20998 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
21003 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
21007 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
21028 AnsiString(AccessNumber));
21030 int Attribute = AccessNumber;
21032 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
21036 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
21040 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
21043 x).XLinkPos] !=
End)
21045 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
21048 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
21099 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
21100 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
21101 int RearwardLinkedRouteNumber;
21104 bool SkipForwardLook =
false;
21113 SkipForwardLook =
true;
21115 RearwardLinkedRouteNumber).
PrefDirSize() - 1, SkipForwardLook)))
21125 int TrainID, TrainPosition, BehindTrainPosition;
21126 bool FoundTrain =
false, BehindTrain =
false;
21127 for(
int x = RouteStartPosition; x >= 0; x--)
21129 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
21154 if(FoundTrain && (TrainPosition > 1))
21158 for(
int x = TrainPosition; x >= 0; x--)
21162 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
21182 BehindTrain =
true;
21183 BehindTrainPosition = x;
21190 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
21207 AnsiString(LookBackwardsFromHere));
21208 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber;
21209 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
21212 bool ExamineRoute =
true;
21214 while(ExamineRoute)
21216 for(
int x = LookBackwardsFromHere; x >= 0; x--)
21261 if(SignalCount >= 3)
21276 LookBackwardsFromHere = CurrentRoute.
PrefDirSize() - 1;
21280 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
21281 ExamineRoute =
true;
21282 LookBackwardsFromHere = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
21317 ExamineRoute =
false;
21332 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
21335 PrefDirElement = InternalPrefDirElement;
21336 if(LockedRouteVector.empty())
21343 bool InLockedRoute =
false;
21347 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
21351 InLockedRoute =
true;
21360 int RouteNumber, VectorCount = 0;
21365 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
21366 if(RouteType == NoRoute)
21379 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
21381 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
21386 PrefDirElement = InternalPrefDirElement;
21387 LockedVectorNumber = VectorCount;
21392 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->RearTrackVectorPosition)
21396 PrefDirElement = InternalPrefDirElement;
21397 LockedVectorNumber = VectorCount;
21418 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
21420 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
21426 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
21436 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
21438 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
21453 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
21455 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
21458 return(GetFixedRouteAt(159, x));
21461 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
21469 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
21471 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
21474 return(GetModifiableRouteAt(15, x));
21477 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
21487 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
21489 TOneRoute OneRoute = GetFixedRouteAt(165, x);
21501 int NumberOfRoutes;
21505 for(
int x = 0; x < NumberOfRoutes; x++)
21512 StoreOneRouteAfterSessionLoad(0, &OneRoute);
21530 if((NumberOfRoutes < 0) || (NumberOfRoutes > 10000))
21537 if((NextID < 0) || (NextID > 1000000))
21542 for(
int x = 0; x < NumberOfRoutes; x++)
21567 AnsiString(StartPosition));
21568 if(EndPosition == StartPosition)
21574 int TVPos = EndPosition;
21575 int LkPos = EndXLinkPos;
21577 while(TrackIsInARoute(15, TVPos, LkPos))
21604 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
21613 if((NewLkPos == 0) || (NewLkPos == 2))
21633 if(TVPos == StartPosition)
21664 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
21677 if(FirstPair.first > -1)
21691 if(SecondPair.first > -1)
21714 if(FirstPair.first > -1)
21728 if(SecondPair.first > -1)
21751 if(FirstPair.first > -1)
21765 if(SecondPair.first > -1)
21788 if(FirstPair.first > -1)
21802 if(SecondPair.first > -1)
21840 "," + AnsiString(DiagonalLinkNumber));
21853 if(FirstPair.first > -1)
21867 if(SecondPair.first > -1)
21884 if(FirstPair.first > -1)
21898 if(SecondPair.first > -1)
21915 if(FirstPair.first > -1)
21929 if(SecondPair.first > -1)
21946 if(FirstPair.first > -1)
21960 if(SecondPair.first > -1)